VR Development — Day#4

Ability to throw objects

Jean-Noel Seneque
3 min readJan 26, 2022


So far in this series, we can pick up and drop objects in our VR world. If you try to throw the object, as soon as you let go of the grabbed object, it drops straight to the ground. We need to track the trajectory of the throwing hand (record interval point along its path), detect when the object is let go, and then based on the trajectory, cause the game object to continue on that path with the same force.

Calculate the throw’s trajectory

In the first step, we need to record the path of the grabbed object. In the GrabbableObject script, create a variable for the amount of throwing force to apply, a list that will store the positions of each frame, and a flag that indicates whether an object is being held.

In the OnGrabStart, we will clear out the list and set it as held.

In the Update method, we start to record each position

Next, we will detect when the object is released calculate the direction based on the last two tracked points. We then add the throwing force in that direction. We also set it as no longer held. Set the _isheld to false in the OnJointBreak method too.

Give it a shot! Press play.

We now have the ability to throw objects around our VR world. With that completed go ahead and turn your XRRig into a prefab so we can reuse it in our next few articles and expand on it.

If you found this article helpful, please give me a Clap, as this brightens my day knowing I may have helped someone in their journey in making games. Also if you would like to see more, “Follow” me, so you will be notified of future releases. You may also send me a message if you need any further help.



Jean-Noel Seneque

A Data & Analytics Consultant who is expanding into developing experiences in XR, Enterprise and Gaming space using Unity www.jeannoelseneque.com

Recommended from Medium