How do I simulate a basketball being shot with physics?

So what I’m trying to do is make a basketball shot like in hoops demo.


The problem is I am very new to scripting and I have no idea how to do it. I already have a shot meter and a shot animation ready, I just need a way to make the ball move to the net.

It’s quite simple actually. First, you need to raycast the player’s mouse into the world space (sounds hard, but many tutorials can be found online). Then, you set the basketball’s velocity towards the position of where the ray intersects the part.

Simple enough.

How do I set velocity of the basketball? Sorry I just started learning coding about a month ago.

It’s very simple. You can set BasePart.AssemblyLinearVelocity or BasePart:ApplyImpulse(Vector3) to set the velocity.

Also how do you raycast the player’s mouse into the world space?

Edit: nevermind figured it out thanks!

this might help?

1 Like