Objects are not repelled when restitution: 1, friction, frictionAir and frictionStatic is 0
Beknur2002 opened this issue · comments
I have 4 cubes and walls created using 4 recatangles. And at the beginning of the game I give the cubes an initial speed, but these cubes do not repel when they collide with a wall
const initialEnemyCube = Matter.Bodies.rectangle(
pos.x,
pos.y,
size.width,
size.height,
{
label: label,
inertia: Infinity,
restitution: 1,
friction: 0,
frictionAir: 0,
frictionStatic: 0,
},
);
And wall
const initialBox = Matter.Bodies.rectangle(
pos.x,
pos.y,
size.width,
size.height,
{
label: 'Box',
isStatic: true,
inertia: Infinity,
isStatic: true,
restitution: 1,
friction: 0,
frictionAir: 0,
frictionStatic: 0,
},
);
And entities
return {
physics: {engine, world},
EnemyCube1: EnemyCube(
world,
'blue',
{x: 100, y: 100},
{height: 40, width: 40},
'first',
'EnemyCube1',
rand1,
),
EnemyCube2: EnemyCube(
world,
'blue',
{x: windowWidth - 100, y: 100},
{height: 40, width: 40},
'second',
'EnemyCube2',
rand2,
),
EnemyCube3: EnemyCube(
world,
'blue',
{x: 100, y: windowHeight - 100},
{height: 40, width: 40},
'third',
'EnemyCube3',
rand3,
),
EnemyCube4: EnemyCube(
world,
'blue',
{x: windowWidth - 100, y: windowHeight - 100},
{height: 40, width: 40},
'fourth',
'EnemyCube4',
rand4,
),
Box: Box(
world,
'black',
{x: windowWidth / 2, y: windowHeight},
{height: 15, width: windowWidth},
),
TopWall: Box(
world,
'black',
{x: windowWidth / 2, y: 0},
{height: 15, width: windowWidth},
),
LeftWall: Box(
world,
'black',
{x: 0, y: windowHeight / 2},
{height: windowHeight, width: 15},
),
RightWall: Box(
world,
'black',
{x: windowWidth, y: windowHeight / 2},
{height: windowHeight, width: 15},
),
};