Hello!
From my
previous discussion, i have draggable walls and player, which is responding to these walls. But player's box2d parameter "fixedRotation" is set to "true" now, and restitution is 0.45.
Now i need to detect if player landed on wall then do something and it bounce off the wall (because of restitution param). Simple image attached.
How can i do this? Maybe raycast will help, but dont know how to apply it...
P.S. Sory for my eng.
">
Comments
http://docs.giderosmobile.com/reference/physics/b2World/Event.BEGIN_CONTACT#Event.BEGIN_CONTACT
P.S. I know about docs, and use them actively.
@antix nah, workaround
This method is a little messy, but I think it's the only way to do it in Box2D. If your game doesn't require rotated objects or polygons, I would very much recommend to use Bump instead of Box2D. It's a lot faster and collisions are handled in a simpler way.
event.contact:getManifold().localNormal
At there, check whether y indicate 1 (or -1 depends on which is fixtureA)
If your object touch slanted object (or circle), y would produce between 1 to 0, so make sure you get y>0.1 value, or such to detect landing event.
You can also get contact point with event.contact:getWorldManifold().points[1]
if it is somehow needed in calculation.
Not forget to mention, these are only working for non-sensor box2d object.
Likes: totebo, rrraptor
You can also use rayCast & queryAABB to help the detection on contact, if somehow it need a complex one.