Golf Game problem

Hi @Alessio_Bonini ,

You could try to introduce some form of damping (or drag) for a ball with this TypeScript code:

const ball = Scene.getItem("Ellipsoid") as Ellipsoid

Time.scheduleRepeating(() =>{
    let dt = 1.0 / 32
    let angularDamping = 0.05
    let linearDamping = 0.05
    ball.physics.angularVelocity = ball.physics.angularVelocity.mult(1.0 / (1.0 + dt * angularDamping))
    ball.physics.velocity = ball.physics.velocity.mult(1.0 / (1.0 + dt * linearDamping))
});

You can play around with the angularDamping and linearDamping parameters if you make them bigger the ball will stop quicker

2 Likes