SetPlayerVelocity help.
#8

The math behind it (move along straight line):

def Vector = (x,y,z)
Vector from = (0,0,0)
Vector to = (1,1,0)
Vector ft = to - from = (1,1,0) - (0,0,0) = (1,1,0)
float length = squareroot(ft.x*ft.x + ft.y*ft.y + ft.z*ft.z) = squareroot(1 + 1 + 0) = 1.41421...
Vector unit = ft/length = (1/1.41, 1/1.41, 0/1.41) = (0.709..., 0.709..., 0)
float speed = 0.5
Vector velocity = speed*unit = (0.5*0.71, 0.5*0.71, 0) = (0.355, 0.355, 0)

SetPlayerVelocity(playerid, velocity.x, velocity.y, velocity.z)

This is pseudo code. If you will understand it you will easily translate it to PAWN.
The key is unit vector: http://en.wikipedia.org/wiki/Unit_vector
Reply


Messages In This Thread
SetPlayerVelocity help. - by De4dpOol - 20.03.2015, 12:50
Re: SetPlayerVelocity help. - by AIped - 20.03.2015, 12:55
Re: SetPlayerVelocity help. - by De4dpOol - 20.03.2015, 12:58
Re: SetPlayerVelocity help. - by fuckingcruse - 20.03.2015, 12:58
Re: SetPlayerVelocity help. - by De4dpOol - 20.03.2015, 13:00
Re: SetPlayerVelocity help. - by IzadorO - 20.03.2015, 13:04
Re: SetPlayerVelocity help. - by De4dpOol - 20.03.2015, 13:07
Re: SetPlayerVelocity help. - by bartekdvd - 20.03.2015, 13:35
Re: SetPlayerVelocity help. - by De4dpOol - 20.03.2015, 14:02

Forum Jump:


Users browsing this thread: 1 Guest(s)