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?