# setVelocity allows body to pass through bodies

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?

• 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. – mythos Mar 10 '16 at 4:55
• I'm using cocos2d-x. – dontangg Mar 10 '16 at 9:02
• Hello @dontangg, do you remember how you fixed this issue? – aumanets Oct 10 '16 at 15:32