Hi!
I’ve been coding this multiplayer .io game recently and I just encountered a problem that I can’t wrap my head around.
So in this game, you control a 2D car which uses the physics calls to move, so applyForce.
Once you go against a wall it stops correctly as expected, but when you align in a way that you should slide off that wall, it sometimes work and others the rigidbody of the car bounces off the wall and it’s in that moment that if you collide with the wall again, the rigidbody velocity gets fucked up and reaches a very high speed in a split second.
I’ve recorded a big ass gif to show you the problem:
Now, all of the game logic runs server-side, the revision of PlayCanvas that I adapted to work headless is 0.205.1 96ca6ae - just in case someone fixed the issue in recent versions, in which case I will have to port the latest version to the server.
The wall’s collisions are made with boxes just like this:
this.arenaWalls[4].addComponent("collision",{
type:'box',
halfExtents: new pc.Vec3(500, 0.5, 0.5)
});
with a rigidbody component set as kinematic.
The cars are capsules (first tried with boxes too, made no difference), like this:
entity.addComponent("collision",{
type: "capsule",
radius: 0.25,
height: 1,
axis: 2
//halfExtents: new pc.Vec3(0.5, 0.5, 0.25)
});
And finally the rigidbody for the cars looks like this:
entity.addComponent("rigidbody",{
type:"dynamic",
linearDamping:0.92,
// limit physics to be 2D
linearFactor: new pc.Vec3(1, 0, 1),
angularFactor: new pc.Vec3(0,0,0),
});
Do you have any possible idea of what could be going on?