Jump to content
Sign in to follow this  
daza

How do i set an object to...

Recommended Posts

How do i set an object such as a flag to face the opposite direction so the tip of flag > is facing direction of a unit? by default a flag placed where a unit is, will have the pointed end facing away.

I want it to have the pointed end towards unit no matter which direction the unit is facing. This is for a script that will create a flag at units position every 30secs or so. I have the script working, but cant figure out how to get the tip of flag facing the unit.

Thanks

Daza

Share this post


Link to post
Share on other sites

you can try something like this:

flag setdir ([flag, getpos unit] call BIS_fnc_dirTo)

make sure you have the funtions module added to your map. You don't need to sync it to anything, just add it.

If that points away from the unit, swap the flag, and the unit.

Share this post


Link to post
Share on other sites

BIS_fnc_dirTo

If the flag isnt pointed to the direction of the pole, then just add/subtract a suitable number.

Share this post


Link to post
Share on other sites

Thanks BigDaddy for your suggestion. That doesnt seem to change anything.

I cant swap them around either, because the flag is suppose to be created on the fly where ever the unit is at the time (while unit is on the move).

BIS_fnc_dirTo

If the flag isnt pointed to the direction of the pole, then just add/subtract a suitable number.

Well thats what i wanted help on, im not very good at maths lol so i wondered if there was a calculation line someone could write up for me. And how do i implement it into the setdir line/code. Thanks.

Daza

Share this post


Link to post
Share on other sites

Here's the code I use to turn to something:

_unit = myUnit;
_pole = myPole;

_spot = getPos _unit;
_myspot = getPos _pole;
_set_dir = ((_spot select 0) - (_myspot select 0))atan2((_spot select 1) - (_myspot select 1)); 
_pole setDir _set_dir;
_pole setPos getPos _pole;    

Untested, but might work. :)

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  

×