hi guys.
i found some strange behavior with contactList in my project.
i was using the BoxMan class and setting maskBits and categoryBits, but when i do that, manifold returns null.
The thing is:
i have one player, enemies and ground. Then i want the player to collide with enemies and ground, the enemies with player and ground but not with each other.
The player uses the BoxMan class from demo. i was setting maskBits and categoryBits, like this:
player
maskBits = 6;
categoryBits = 8;
enemies
maskBits = 10;
categoryBits = 4;
ground
maskBits = 12;
categoryBits = 2;
This doesnt works. It seems contact it's always empty. So manifold its always null and BoxMan cant jump.
what im doing wrong?
sorry for my bad english.
i found some strange behavior with contactList in my project.
i was using the BoxMan class and setting maskBits and categoryBits, but when i do that, manifold returns null.
The thing is:
i have one player, enemies and ground. Then i want the player to collide with enemies and ground, the enemies with player and ground but not with each other.
The player uses the BoxMan class from demo. i was setting maskBits and categoryBits, like this:
player
maskBits = 6;
categoryBits = 8;
enemies
maskBits = 10;
categoryBits = 4;
ground
maskBits = 12;
categoryBits = 2;
Code:
if(!contacts.isEmpty()) {
contacts.forEach(function(keys:Array, c:ContactEvent) {
var wm:b2WorldManifold = c.getWorldManifold();
if(wm.normal) {
var d:Number = wm.normal.dot(gravity);
if(!manifold || d > dot) {
manifold = wm;
dot = d;
}
}
});
contacts.forEach(function(keys:Array, c:ContactEvent) {
var wm:b2WorldManifold = c.getWorldManifold();
if(wm.normal) {
var d:Number = wm.normal.dot(gravity);
if(!manifold || d > dot) {
manifold = wm;
dot = d;
}
}
});
This doesnt works. It seems contact it's always empty. So manifold its always null and BoxMan cant jump.
what im doing wrong?
sorry for my bad english.