SA-MP Forums Archive
Player Velocity etc. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Player Velocity etc. (/showthread.php?tid=179105)



Player Velocity etc. - sekol - 25.09.2010

I must know how to make SetPlayerVelocity work on player facing angle, so if he uses /megajump, he jumps few meters in his facing direction.


Re: Player Velocity etc. - Mauzen - 25.09.2010

Fear the power of trigonometry!

pawn Код:
new Float:vx, Float:vy, Float:vz;
new Float:rot;
GetPlayerFacingAngle(playerid, rot);
rot = 360 - rot;    //Dont know how to evade this line, and too lazy to test it out ;)

GetPlayerVelocity(playerid, vx, vy, vz);
SetPlayerVelocity(playerid, vx + jumpspeed * floatsin(rot, degrees), vy + jumpspeed * floatcos(rot, degrees), vz + zjumpspeed);



Re: Player Velocity etc. - sekol - 25.09.2010

Difficult script O.o


Re: Player Velocity etc. - Mauzen - 25.09.2010

Ok, use it like this then (just copy and use the function)

pawn Код:
stock MegaJump(playerid, Float:forwardspeed, Float:upwardspeed)
{
    new Float:vx, Float:vy, Float:vz;
    new Float:rot;
    GetPlayerFacingAngle(playerid, rot);
    rot = 360 - rot;

    GetPlayerVelocity(playerid, vx, vy, vz);
    SetPlayerVelocity(playerid, vx + forwardspeed * floatsin(rot, degrees), vy + forwardspeed * floatcos(rot, degrees), vz + upwardspeed);
    return 1;
}
You can just call this function when a player type /megajump or so. Experiment a bit with the size of forward and upwardspeed. For normal use something below 1.0 should be enough, but try how you like it


Re: Player Velocity etc. - Jaxson - 21.10.2010

This is exactly what I was looking for! Thanks!