0
\$\begingroup\$

In my game, I'm using cocos2d-x and I wanted to have an object that changes direction immediately, so I used setVelocity() on the physics body to do that.

However, when I do that it can run through my physics body that surrounds the screen. It bumps into it, but ultimately, it gets through. I tried increasing how thick this other body is, and that does successfully prevent it from getting all the way through, but it still makes progress into the body before getting ejected out.

So, for now, I have changed it to move by calling applyImpulse(). With this method, it hits the edge and works the way I'd expect. However, the movement behavior is different than I'd like for this case.

Some have said that they increased the number of substeps taken by the physics engine. I could do that, but it feels like something else is wrong.

Has anyone run into this before?

\$\endgroup\$
3
  • \$\begingroup\$ Can you elaborate on your issue at hand? Are you using a physics library, or building your own? You want to use ApplyImpulse and ApplyForce methods. \$\endgroup\$
    – mythos
    Mar 10, 2016 at 4:55
  • \$\begingroup\$ I'm using cocos2d-x. \$\endgroup\$
    – dontangg
    Mar 10, 2016 at 9:02
  • \$\begingroup\$ Hello @dontangg, do you remember how you fixed this issue? \$\endgroup\$
    – aumanets
    Oct 10, 2016 at 15:32

0

You must log in to answer this question.

Browse other questions tagged .