Spawn random around the player
#2

This could be accomplished by offsetting the players position with sin and cos variables (with changing the angle too). That way you're not just restricted to the x and y axis.

pawn Code:
new Float: x, Float: y, Float: z, Float: a;
GetPlayerPos( playerid, x, y, z );
GetPlayerFacingAngle( playerid, a );
a += random( 360 );
x += ( random( 10 ) * floatsin( -a, degrees ) );
y += ( random( 10 ) * floatcos( -a, degrees ) );
CreateObject( 0, x, y, z, 0.00, 0.00, 0.00 );
Notes:
- The random( 360) will add a random value to the angle, so it spawns at a different direction from the player
- The random( 10 ) will add a random value from the player, so they'll be at different distances, not always 5, or whatever
- If you would like a constant distance from the player, exchange random( 10 ) with the number of units you desire
- You could place this code under some type of timer
Reply


Messages In This Thread
Spawn random around the player - by DaneAMattie - 18.07.2011, 10:42
Re: Spawn random around the player - by Bakr - 18.07.2011, 10:51
Re: Spawn random around the player - by DaneAMattie - 18.07.2011, 13:44
Re: Spawn random around the player - by park4bmx - 18.07.2011, 14:54
Re: Spawn random around the player - by DaneAMattie - 18.07.2011, 15:36

Forum Jump:


Users browsing this thread: 1 Guest(s)