1
\$\begingroup\$

I want to move the object (CCNODE) with constant speed in any direction , what i have did till now is applied a force to object at start to get it moving and set elasticity as 1 and friction as 0 to every object which it will collide .

After some time speed goes on increasing , is there any way so i can check if speed increased so that i can control it or to apply velocity instead of force . Thanks !

\$\endgroup\$
  • \$\begingroup\$ what about adding CCMoveBy action? wrapped inside CCRepeatForever? \$\endgroup\$ – Ali1S232 Oct 6 '14 at 0:54
  • \$\begingroup\$ Problem in this is when the CCNode collide with some other node it does not change the direction .It continue to move in same direction. Is there any way to change the direction ? \$\endgroup\$ – Meuk Light Oct 6 '14 at 17:50
  • \$\begingroup\$ Why not set CCNode.physicsBody.velocity, does that not fit your requirements? \$\endgroup\$ – user5665 Jul 18 '16 at 1:29
1
\$\begingroup\$

You can check the velocity in your update function and set it to some max value if the calculated value will be greater than that max. This way you still use force and allow it to stop when it collides with another object, but it will never be able to go faster than the maximum velocity you set.

\$\endgroup\$
1
\$\begingroup\$

Just slow it down or speed it up with a force proportional to the error.

If your intentions were to hit a certain position for your object, you would actually need something more advanced like a Proportional Integral Differential Controller.

But if you merely aim for a certain velocity, not a certain position, then its quite easy by setting a force each frame.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.