Jump to content
Undeceived

Place unit in front of vehicle

Recommended Posts

Well, this is probably an easy one  :icon_biggrin: but I'm simply not able to create an universal solution for it.

 

I want a mechanic to be setPossed just in front of every type of vehicle, so he can then perform a good looking repair animation.

 

This is a neat piece of code, but unfortunately it doesn't take into account the different size of different vehicles:

mechanic setPos (damagedVehicle getpos [+3, getdir damagedVehicle]);

The result is that for bigger vehicles the mechanic will be setPossed into the hood. For smaller ones he will be setPossed too far away so that his hands are way too far from the vehicle.

 

Any idea how to do this? Maybe something with bounding boxes or so?

 

Thanks a lot! 

Share this post


Link to post
Share on other sites

Not sure if the bounding box is defined the same for each vehicle. But something like this then:

private _bbox = boundingBoxReal damagedVehicle;
private _frontDist = _bbox select 1 select 1; //This seems to be the edge of the front of the bounding box
private _worldPos = damageVehicle modelToWorld [0, _frontDist, 0];
_worldPos set [2, 0]; // Ensure we placed on ground
mechanic setPos _worldPos;

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×