I have been trying to make a trailer parking game for long. After a long time I have just built the first goal that steering works!. But I don’t know how to make formula for trailer?
I made function for steering with that:
if (cursors.up.isDown) { this.__araba.body.angularVelocity = this.normal(this.__wheel.angle) this.physics.velocityFromAngle(this.__araba.angle-90, 300, this.__araba.body.velocity) // this.__araba.body.angularVelocity = -10 } else if (cursors.down.isDown) { this.__araba.body.angularVelocity = this.normal(-this.__wheel.angle) this.physics.velocityFromAngle(this.__araba.angle-90-180, 300, this.__araba.body.velocity) }
for normalization function:
this.normal = (angle) => { if (angle === 0){ return 0; } else if (angle > 0){ return angle/90*100; } else if (angle < 0){ return angle/90*100 } }
but. i don’t know how to make traile physics function.
demo link: https://html5.ozguruygulama.com/romork/dist/index.html