Golf Game problem

Hello everyone, I’m working on a game called “Golf Star” and I have a problem with the physics of the ball that takes a long time to stop if I don’t impose it on static, does anyone have any ideas to solve the problem by changing friction or weight of the ball?

1 Like

@EdTechnocation you are a game expert, so maybe you have a good suggestion.

2 Likes

Hi, @Alessio_Bonini! I have your Golf Star CoSpace a try. The physics settings of the ball seem fine to me. However, the ball doesn’t want to go in the correct direction each time I press “e”. I see that the ball is supposed to go in the direction of a hidden “cube”. But that doesn’t seem to true every time. I’ll keep tinkering with it though. Cool idea by the way!

3 Likes

Hi @EdTechnocation, thank you for the help.

2 Likes

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

Hi @Dmitry, thank you it works very well!