Jump to content

Recommended Posts

Posted

I want to move a model using PhysicsSetPosition, the problem it is not as smooth as using SetVelocity,

but i need PhysicsSetPosition to control some values in Z axis.

 

So when you press a move right key i add some value to X position of the model : It is incremental so not smoothed. What formula or how to do it ? There is something in FPS Player script but i didn't understood ?

Must i add the incremental value in UpdatePhysics ? using time factor ? when to smooth the value ?

 

Any ideas are welcome :)

Stop toying and make games

Posted

I'm not 100% certain I understand the question so feel free to ignore this if I got it wrong ;)

 

I think the problem is that you are adding force in a linear, which gives the wrong look/feel - so usually it's the force is distributed over a curve. I know that is somewhat hard to visualize - this may help : http://easings.net/

 

For instance the "easeInOutBack" function would be suitable for jumping

  • Upvote 1

System:

Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k

Posted

Thanks.

I don't know if PhysicsSetPosition uses AddForce ? The problem is the movement seems jerky not as smooth as using SetVelocity.

Your cuves examples are great to simulate car breaking or acceleration or some mechanism.

For linear velocity i think i'll have to use perhaps Time and a formula to have constant distance over time.

Stop toying and make games

Posted

If you want smooth movement, you could use the Curve method that is a part of the Leadwerks Math library to return an interval between the current object's position and the desired object's position. My example is for the movement of a camera, but I think you can get the idea. ex.

 

m_camera->SetPosition(
Math::Curve(Position().x, m_camera->GetPosition().x, m_fCameraSmoothing),
Math::Curve(Position().y, m_camera->GetPosition().y, m_fCameraSmoothing),
Math::Curve(Position().z, m_camera->GetPosition().z, m_fCameraSmoothing));

Posted

@Aggror :

Your code is for some entity following another.

So i think i'll have to make some invisble collision model for PhysicSetPosition, and position the visible 3D model with the smoothed position. In fact the follow code will apply to invisible physic position and to it's 3D visible model.

Stop toying and make games

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...