Collision detection without impecting in Box2d Javascript
box2d, collision, javascript
Solution
Aahhhh... Finally Got the solution from stackoverflow itself. here it is.
How to detect collision but do not collide in box2d?
i was using wrong keyword. its is
fixturedef.isSensor = true;
Thats It ;) and to detect the collision we have to write the listener like this
world.SetContactListener(listener);
var listener = new Box2D.Dynamics.b2ContactListener;
listener.BeginContact = function(contact) {
// console.log(contact.GetFixtureA().GetBody().GetUserData());
div = document.getElementById("textUI");
div.innerHTML = "Come "+contact.GetFixtureA().GetBody();
defaultCarSpeed = defaultCarSpeed/2;
}
listener.EndContact = function(contact) {
// console.log(contact.GetFixtureA().GetBody().GetUserData());
div = document.getElementById("textUI");
div.innerHTML = "Go "+contact.GetFixtureA().GetBody();
defaultCarSpeed = defaultCarSpeed*2;
}
Problem
I am creating a Car Race Game, Where i need help in Car over some rough surface area by Box2d Javascript. - I created Car game by following link http://www.codekites.com/make-racing-car-box2d-javascript/ - Also created obstacles. Question: - Now i want such obstacles, which should not be collide with Car. But when Car goes over that shape, then Car become slow. So please help me, how to go with that. i found IsSensor, but that is not working. So please let me know, how to go with this.