Collisions not working at all
Closed this issue · 1 comments
ziarmandhost commented
Hello, @schteppe !
I have multiplayer game and running p2.js from server using nodejs module: v0.7.1. I have 2 entities: player and wall. Also I have this setup:
export const COLLISION_GROUPS = {
PLAYER: Math.pow(2, 1),
SOLIDBLOCK: Math.pow(2, 2),
SPRING: Math.pow(2, 3)
}
Player
this.body = new p2.Body({
type: p2.Body.DYNAMIC,
mass: PLAYER.weight,
position: [0, 0],
fixedRotation: true,
collisionGroup: COLLISION_GROUPS.PLAYER,
collisionMask: COLLISION_GROUPS.SOLIDBLOCK | COLLISION_GROUPS.SPRING
});
this.body.addShape(new p2.Box({
width: 160,
height: 249,
material: MATERIALS.PLAYER
}));
Wall
this.body = new p2.Body({
type: p2.Body.STATIC,
// mass: 1,
position: [x, y],
// fixedRotation: true,
collisionGroup: COLLISION_GROUPS.SOLIDBLOCK,
collisionMask: COLLISION_GROUPS.PLAYER,
});
this.body.addShape(new p2.Box({
width,
height,
material: MATERIALS.SOLIDBLOCK
}));
- this is my world creation:
Problem
Player passthough walls. I sending positions to client and it just rendering it.
ziarmandhost commented
Problem was with how I add object to world. Typo in name of property of class that contain world.