Jump to content
Sign in to follow this  
Mr_B_A_Baracus

Finding Player Position Relative To Vehicle

Recommended Posts

Hi, I'm working on a script that uses custom 'get in as driver' type actions for reasons that I'll not get into right now! I have it working OK for land vehicles using nearEntities but due to the different sizes of the vehicles (New Trucks vs Quads!) my radius for the command appearing has to be quite large meaning you can get in a quad from a stupid distance.

IIRC, the standard options only appear when you are at the correct location relative to the vehicle, e.g. To get in as driver you must be at the drivers door, front passenger needs to be at the passenger side, etc. Is there any command or function that will do this for me or any other relatively simple way to do this? I guess you could probably have an array and work out these positions for every vehicle but unfortunately maths makes my head hurt and I don't get a lot of scripting time!

Thanks in advance.

Share this post


Link to post
Share on other sites

OK, thanks, I'm guessing I would still need to keep an array with rough dimensions of each vehicle for this to work though, does this information already exist somewhere?

Share this post


Link to post
Share on other sites

Look at

http://community.bistudio.com/wiki/boundingBox

http://community.bistudio.com/wiki/boundingCenter

http://community.bistudio.com/wiki/boundingBoxReal

all entry points for drivers, gunners, etc are defined in model memory points, i don't think you can fetch them through a script in normal way. http://community.bistudio.com/wiki/attachTo lets you attach objects to memory points, if it works for vehicles then you might make a script that will parse all vehicles, attach temp object to driver seat memory point, get relative coordinate (worldToModel) and then dump you an array that you can use instead of finding offsets for driver seats by hand for each vehicle.

Share this post


Link to post
Share on other sites
Look at

http://community.bistudio.com/wiki/boundingBox

http://community.bistudio.com/wiki/boundingCenter

http://community.bistudio.com/wiki/boundingBoxReal

all entry points for drivers, gunners, etc are defined in model memory points, i don't think you can fetch them through a script in normal way. http://community.bistudio.com/wiki/attachTo lets you attach objects to memory points, if it works for vehicles then you might make a script that will parse all vehicles, attach temp object to driver seat memory point, get relative coordinate (worldToModel) and then dump you an array that you can use instead of finding offsets for driver seats by hand for each vehicle.

Perhaps overkill, but you can use selectionPosition to get the position of memory points in model.

Eg.

_vehicle = ...;

_memPointDriver = getText (configFile >> "cfgVehicles" >> _vehicle >> "memoryPointsGetInDriver"); //  typically "pos driver";

_modelPos = _vehicle selectionPosition _memPointDriver;
_worldPos = _vehicle modelToWorld _modelPos;

These work as well:

memoryPointsGetInDriver    //  typically "pos driver"
memoryPointsGetInDriverDir //  typically "pos driver dir"
memoryPointsGetInGunner    //  typically "pos gunner"
memoryPointsGetInGunnerDir //  typically "pos gunner dir"

Edited by mrflay
fixed typo

Share this post


Link to post
Share on other sites
Perhaps overkill, but you can use selectionPosition to get the position of memory points in model.

Oh, never used this command before and didn't manage to find it by searching for "memory point". Thanks.

Share this post


Link to post
Share on other sites

Thanks guys, boundingBoxReal will definitely help and if I get the chance I will try the memory point stuff, only just started scripting in the last few weeks so that might take me a while to figure out!

Edited by Mr_B_A_Baracus
typo

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
Sign in to follow this  

×