Jump to content

[SOLVED]setElementVelocity weirdness


madis

Recommended Posts

Hi,

I'm trying to do a

'ish rope for fun. I'm a bit stuck on having a quality method to move the player on the rope.

I got somewhat OK result by changing Element position with interpolateBetween. However, it might be nicer to use setElementVelocity, because it would allow to let go from the rope and still have some velocity left (you can see usefulness of that in the Liero video). Also it would solve the problem of going through objects. The problem is, that setElementVelocity seems to throw the player in quite random position.

local a,b,c = getElementPosition(localPlayer) 
x_target, y_target, z_target = unpack(g_Rope.targetPos) 
-- This one actually works, got it from someone else's script 
wanted_ped_angle = (360-math.deg(math.atan2(( x_end-a ),( y_end-b ))))%360; 
setPedRotation(localPlayer, wanted_ped_angle); 
-- These don't seem to affect the velocity behaviour, so commented out: 
--setPedLookAt(localPlayer ,x_end, y_end, z_end, 0) 
--setPedAimTarget(localPlayer ,x_end, y_end, z_end) 
  
-- There seems to be a problem moving the player when on ground, so let's give a lift 
if  isPedOnGround then 
  setElementPosition(localPlayer, a,b,c+1, false) 
end 
  
setElementVelocity(localPlayer, 0.2, 0, 0) 

It does move the player if I'm not on the ground, but it seems to move the player in random position.

Should I change the parameters in setElementVelocity? Are there anything more than speed in these actually?

Edited by Guest
Link to comment
  • Moderators
The problem is, that setElementVelocity seems to throw the player in quite random position.

No but just in the X axis of the GTA world ( it's not Z instead ??? ) and you want the player's axis right ?

and I seen an error ( fixed here ):

if  isPedOnGround( localPlayer ) then 
  setElementPosition(localPlayer, a,b,c+1, false) 
end 

Link to comment

It should be all of these, I guess. If the rope has been shot just in front of you, there's no z though.

Even if I don't set Y velocity, it should still move in the right direction on one axis, imo. But while testing I got the opposite direction quite often.

Edited by Guest
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...