Player Velocity etc.
#1

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.
Reply
#2

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);
Reply
#3

Difficult script O.o
Reply
#4

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
Reply
#5

This is exactly what I was looking for! Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)