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

--

--

Jean-Noel Seneque

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