I am building a basic platforming game using ExcaliburJS physics. I enabled physics in the main game and in my Actor elements. This all works according to the example code, with the exception of these physics properties:
this.body.bounciness //and friction, mass, inertia
this.body.limitDegreeOfFreedom.push(DegreeOfFreedom.Rotation)
The body does not bounce, and can still rotate around the z axis. The whole class:
export class Mario extends Actor {
constructor(texture) {
super({ width: texture.width, height: texture.height }) // collision box size is working
this.graphics.use(texture.toSprite())
// enable physics
this.body.useGravity = true // working
this.body.collisionType = CollisionType.Active // working
this.body.bounciness = 0.7 // not working
this.body.limitDegreeOfFreedom.push(DegreeOfFreedom.Rotation) // not working
// all the console logs are working
console.log(this.body.mass)
console.log(this.body.inertia)
console.log(this.body.bounciness)
console.log(this.body.friction)
console.log(this.body)
}
}
In my game I enable physics with
class Game {
constructor(){
Physics.useRealisticPhysics()
Physics.gravity = new Vector(0, 800)
this.engine = new Engine()
// ...
}
}
How can I add bounciness and limit rotation on the z axis in ExcaliburJS?