AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Attach entity to vehicle (car) (https://forums.alliedmods.net/showthread.php?t=316312)

karaulov 05-17-2019 04:40

Attach entity to vehicle (car)
 
Sorry for strange question :)




How to attach object(brush entity) to vehicle ? (Moving and turning it with car.)


I tried, but I can only move it with car (like origin += neworigin - oldorigin).


How to add angles/and move coordinates with these angles ? (Full attach)

hleV 05-17-2019 08:43

Re: Attach entity to vehicle (car)
 
Code:
entity_set_edict(brush, EV_ENT_aiment, vehicle); entity_set_int(brush, EV_INT_movetype, MOVETYPE_FOLLOW); // May be unnecessary, test

karaulov 05-17-2019 09:37

Re: Attach entity to vehicle (car)
 
I got server error :

---------------------------
Fatal error - Dedicated server
---------------------------
SV_HullForEntity: SOLID_BSP without MOVETYPE_PUSH
---------------------------
ОК
---------------------------


I change SOLID_BSP to SOLID_BBOX and ... got strange result.

It works, but brush entity attached to vehicle, got big offset from needed point.



How to works MOVETYPE_FOLLOW? Possible to simulate it manual ? (func_breakable stop works after MOVETYPE_FOLLOW)

karaulov 05-17-2019 10:00

Re: Attach entity to vehicle (car)
 
Code:

// Just copy angles and origin of parent
void SV_Physics_Follow(edict_t *ent)
{
        // regular thinking
        if (!SV_RunThink(ent))
                return;

        edict_t        *parent = ent->v.aiment;
        if (!ent->v.aiment)
        {
                Con_DPrintf("%s movetype FOLLOW with NULL aiment\n", &pr_strings[ent->v.classname]);
                ent->v.movetype = MOVETYPE_NONE;
                return;
        }

        VectorAdd(parent->v.origin, ent->v.v_angle, ent->v.origin);
        VectorCopy(parent->v.angles, ent->v.angles);

        SV_LinkEdict(ent, TRUE);
}

from hlds code

<VeCo> 05-17-2019 11:50

Re: Attach entity to vehicle (car)
 
You could try to make your own point entity that acts as func_breakable? Setting origin to brush entities directly this way might make them act weird, aiment wasn't meant to work with them (that's why entity_set_origin exists).

The offset might be because the origin of the vehicle isn't where you need it to be? In that case, aiment might not be useful anyway, you'd still need to manipulate the entity origin to compensate for that offset... (and yeah, that would look choppy).

karaulov 05-18-2019 00:31

Re: Attach entity to vehicle (car)
 
I tried attach for example 'func_breakable' (brush entity from map) to vehicle.

Yes, set_origin works, but not rotate func_breakable with vehicle, and with some problems.
Possible need use velocity/speed/ etc instead of change origin. But it very hard ?

karaulov 05-18-2019 00:35

Re: Attach entity to vehicle (car)
 
Quote:

Originally Posted by <VeCo> (Post 2652014)
You could try to make your own point entity that acts as func_breakable? Setting origin to brush entities directly this way might make them act weird, aiment wasn't meant to work with them (that's why entity_set_origin exists).

The offset might be because the origin of the vehicle isn't where you need it to be? In that case, aiment might not be useful anyway, you'd still need to manipulate the entity origin to compensate for that offset... (and yeah, that would look choppy).



Possible aiment not works because func_breakable from map (brush) not have 'rotation point' ? It can be changed manually ?


I found https://forums.alliedmods.net/showpo...7&postcount=11 but it only for angles.

<VeCo> 05-18-2019 16:48

Re: Attach entity to vehicle (car)
 
Yeah, that's another problem. It would be pretty much impossible to achieve smooth movement without aiment.
You could try mimicking the velocity instead of origin but it would be a pain with the collision checking.

hleV 05-19-2019 09:04

Re: Attach entity to vehicle (car)
 
If editing the brush model is an option, you could move it so it'd better align with the car.


All times are GMT -4. The time now is 01:11.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.