YouGroove Posted April 9, 2014 Share Posted April 9, 2014 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 Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Guppy Posted April 10, 2014 Share Posted April 10, 2014 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 1 Quote System: Linux Mint 17 ( = Ubuntu 14.04 with cinnamon desktop ) Ubuntu 14.04, AMD HD 6850, i5 2500k Link to comment Share on other sites More sharing options...
YouGroove Posted April 10, 2014 Author Share Posted April 10, 2014 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. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Joshua Posted April 11, 2014 Share Posted April 11, 2014 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)); Quote Link to comment Share on other sites More sharing options...
YouGroove Posted April 11, 2014 Author Share Posted April 11, 2014 Thanks Joshua. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
AggrorJorn Posted April 11, 2014 Share Posted April 11, 2014 You might find this of interest. http://www.leadwerks.com/werkspace/files/file/470-follow/ 1 Quote Link to comment Share on other sites More sharing options...
YouGroove Posted April 11, 2014 Author Share Posted April 11, 2014 @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. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
Recommended Posts
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.