Jump to content

Problem With SetElementVelocity


capitanazop

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...