Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects are not repelled when restitution: 1, friction, frictionAir and frictionStatic is 0 #1243

Closed
Beknur2002 opened this issue Sep 22, 2023 · 0 comments

Comments

@Beknur2002
Copy link

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},
),

};

@Beknur2002 Beknur2002 changed the title Objects are not repelled when restitution: 1, friction: 0, frictionAir: 0, frictionStatic: 0 Objects are not repelled when restitution: 1, friction, frictionAir and frictionStatic is 0 Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant