Sphere slightly curve when adding applyImpulse using CannonJS

Hello guys! I hope you are doing good!

I’m facing some strange behaviour with my project. I did a quick playground to illustrate the core system of my issue. At the moment, the player can aim via the pointers where the sphere should go using a simple raycast system. However, the sphere doesn’t properly follow its trajectory. By pressing the key ‘A’, the player will apply some force to the ball according to its given direction.

Here’s the playground : https://playground.babylonjs.com/?fbclid=IwAR3uxn0PUD19hUoEehRfwVRb3HBSG5lyOVNvcFhJPre8d2paY2mq5DDU8j4#7UCMPP#18

Am I missing something? Thanks!

Hello! I’m doing good, what about you? :smiley:

There is just a few things that need adjustment here: I removed the friction and restitution from the sphere and ground because they could interfere. And the other thing is that, as soon as the ball is launched, I disable the pointer events, because they were still happening while the ball was in trajectory, and they were changing the ball rotation which was interfering too: CurvingBall | Babylon.js Playground (babylonjs.com)

Thanks for the quick feedback!

I forgot to add the ‘forceApplied’ that you just added in the playground hehe. However, I would like my sphere to roll on the ground and not slide on it. If a remove the friction of the sphere and the ground, the sphere will only slide on it…

You can apply the force sligthly up on the ball instead of the middle so it rolls around: CurvingBall | Babylon.js Playground (babylonjs.com)
I was able to add friction on the sphere too, but adding on the ground is what seems to mess up the trajectory more


Thanks a lot! You can’t imagine how many time I passed on this little issue…

1 Like