Jump to content
anthonyfromtheuk

Call marker in front of player

Recommended Posts

I am using this to create a marker randomly near my player unit. It spawns the marker in a random direction within 100 meters

_marker1 = createMarker ["marker1", [player, 100, random 360] call BIS_fnc_relPos ];

Does anybody know how to make the marker spawn in front of the player instead of just randomly?

 

So say for example the players facing dead north then the marker will spawn some where between 270 and 90 degrees?

The marker would spawn somewhere in the red area on the image below if the player was facing north.

2l8ubk3.jpg

Even just being able to choose a range of bearings the marker will spawn in would be useful such as 270 to 90 degrees regardless of what direction the players facing

but really I would like the players current direction to be used as a centre point and for the the marker to spawn some where 180 degrees ahead of him

So if the player was facing west instead then the marker will spawn in the red below instead.

27zjifb.jpg

 

Thanks if you can help
 

  • Like 1

Share this post


Link to post
Share on other sites
_angleSector = 180;
_dir = getDir player;
_randomAngle = random _angleSector;
_from = _dir - ( _angleSector / 2 );
_pos = [ player, 10, _from + _randomAngle ] call BIS_fnc_relPos;

Where _angleSector is the range you want to cover so 180 as per the red area in your post.

You then take half of this area away from the direction the player is facing ... _from

Your position then ends up being _from + a random amount from the _angleSector

  • Like 1

Share this post


Link to post
Share on other sites

I tried this out and it is perfect as you can see in the image! All those enemy have been spawned using the random marker while I am in the middle facing the direction of the blue arrow.

 

30mloy1.jpg

 

Sorry for posting a big ugly image
 

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

×