Move player to facing angle ?
#1

Hi, I need help, how could I move player to his facing angle ?
so that I would set player position where he is but 4meters more to his facing angle
Reply
#2

I don't quite understand what you're asking but if you're looking to get the coordinates a certain distance in front of the player's position this function is extremely useful:

Код:
GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance) {

	new Float:a;
	
	GetPlayerPos(playerid, x, y, a);
	GetPlayerFacingAngle(playerid, a);
	
	if (GetPlayerVehicleID(playerid)) {
	
	    GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
	    
	}
	
	x += (distance * floatsin(-a, degrees));
	y += (distance * floatcos(-a, degrees));
	
}
Here's an example of how you could use it:

Код:
new Float:pos[3];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetXYInFrontOfPlayer(playerid, pos[0], pos[1], 4.0);
Reply
#3

I need that when I do certain thing that player would set pos and that pos would be x,y,z but to the position would be added distance by facing angle.
exemple:
i'm looking to east and then i write /pos and it would set my position to the same one but move little bit where i was looking (face angle)

THANKS! YOUR CODE WORKS PERFECTLY
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)