I’m trying to make it so that when you press the w key it propels you forward in the direction you are facing and when you press the a,s and d keys you are also propelled in another direction appropriate to where you’re facing (so that if you for example press a, you will be strafed to the left).
I thought it would be possible to just subtract a vector from ply:GetAimVector(), but after numerous tests it has proved impossible. I have tried both simply subtracting a number as well as subtracting a number already taken from the AimVector (like in the linked example).
Neither of these things have worked and have always propelled the player in a certain direction and not one relative to the way the player faces.
Here’s my example so far:
[lua]function ForwardKey(ply, key)
if key == IN_FORWARD then
ply:SetVelocity( ply:GetAimVector()*500 )
if key == IN_MOVELEFT then
playerleftmod = ply:GetAimVector()-(ply:GetAimVector()-Vector(0, 1 , 0))
ply:SetVelocity( (ply:GetAimVector()+playerleftmod)*500 )
print(ply:GetAimVector()-Vector(90, 0, 0))
hook.Add(“KeyPress”, “Forward Key Pressed”, ForwardKey)[/lua]