Jump to content
Sign in to follow this  
special ed

Set a x,y,z position in a strait line out from a units Direction, any known formulas

Recommended Posts

Hello

I'm really useless at math, especially any type of formula. I was wondering if anyone might know of, or make use of a formula that would provide an x,y,z position that would be set in a strait line out from a units direction, at a given distance.

The reason for this would be to repeatedly set a DoWatch unit direction on certain units in combat to orient their facing constantly in the direction the units are heading - primarily to prevent them from doing the random scanning and occasional staring at nearby walls and various directions other than the direction they are moving in.

Tia :)

Share this post


Link to post
Share on other sites

If the direction is always directly ahead, or to the side of the unit (and never at a random direction from it), you can also use modelToWorldVisual. So a position 3m ahead of a player would be:

_unit modelToWorldVisual [0,3,0];

This is much faster than using BIS_fnc_relPos in this case.

Share this post


Link to post
Share on other sites

Just so I fully understand it, the difference between modelToWorld(Visual) and BIS_fnc_relPos is that BIS_fnc_relPos is to get a relative position (only X and Y) at any relative angle while modelToWorld(Visual) gets a relative position only before, behind, left or right (plus height) of the object?

Share this post


Link to post
Share on other sites
Just so I fully understand it' date=' the difference between [b']modelToWorld(Visual[/b]) and BIS_fnc_relPos is that BIS_fnc_relPos is to get a relative position (only X and Y) at any relative angle while modelToWorld(Visual) gets a relative position only before, behind, left or right (plus height) of the object?

Basically yep, you can use them similarily but with modelToWorld you are calculating the x and y values for the angle you want manually ( [3,3,0] would be 45 degrees for example and with some trig you could do any angle, really). You are correct in that relPos doesn't calculate height and I dont believe it considers the vectorUp of the object either. I find modelToWorld far more flexible to use because of this.

Share this post


Link to post
Share on other sites
If the direction is always directly ahead, or to the side of the unit (and never at a random direction from it), you can also use modelToWorldVisual. So a position 3m ahead of a player would be:

This is much faster than using BIS_fnc_relPos in this case.

Nice. Thanks for the heads up on that alternative method. Planning on running it every .5 seconds, so it sounds like this would be more appropriate due to speed.

Thanks everyone for the help. :thumbs-up:

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  

×