'Android Box2D how to make the collision work while changing the circle position?
I'm new in Box2D lib and also new in GlSurfaceView so I need your help!!! I'm using the Box2D lib with android GlSurfaceView, and I'm trying to implement simple touch and move effect for my bubbles. I've successfully converted the android screen pixels to box2D world points and I can move the circles as expected but the collision doesn't work,,, In this case (the circle which I'm moving) can touch the other circles without any collision. What can I do to make the collision work?
When I'm changing the circles position with applyForce or applyLinearImpulse then the collision works fine, but the collision doesn't work when I'm changing the position with just setting the x and y coordinates.
Solution 1:[1]
How do I move a body/actor by dragging the mouse/finger?
The other circle might be sleeping and unable to detect a contact, try disabling sleeping.
circleBody.setSleepingAllowed(false);
i.e. because teleportation is outside of box2d collision resolution the circle doesn't wake up automatically as it does when its collided with normally.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | londonBadger |