capitanazop Posted November 28, 2009 Share Posted November 28, 2009 hi i create a function for jump with H key and work but i had a problem with the SetElementVeloctiy. me = getLocalPlayer(); function jump2(player) if isPedOnGround ( me ) then local velx, vely, velz = getElementVelocity( me ) setElementVelocity( me, velx, vely, velz+0.1 ) else outputChatBox ( "you Can't jump in the air!") end end the problem is everytime jump the same heigh i tried with 0.1 0.001 161 1.2 etc... and jump the same everytime. bye and sorry for my english Link to comment
50p Posted November 28, 2009 Share Posted November 28, 2009 Debug your script. Check what setElementVelocity and getElementVelocity return. Link to comment
capitanazop Posted November 28, 2009 Author Share Posted November 28, 2009 any error or warning, the function work great but the numbers dont take effect. Link to comment
subenji99 Posted November 28, 2009 Share Posted November 28, 2009 In an odd twist of irony considering what you are trying to accomplish, setElementVelocity behaves oddly when used on peds that are on the ground, but works perfectly fine once airborne. (I see the behaviour as peds on the ground are completely restricted to movement by animations only. Set velocity only works for a single frame.) You should be able to solve this by applying the velocity a second time, 1 frame later (via onClientRender, or a timer if serverside - but the timer will be less reliable) as at that point the ped should be airborne. Link to comment
Dark Dragon Posted November 28, 2009 Share Posted November 28, 2009 the z velocity is a bit buggy for peds and players, why don't you try to set the gravity instead? Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now