Curving the Teleport Raycast!

addam davis
3 min readJan 25, 2024

Currently in this project we have no visual representation for when we are pressing forward on the joystick, meaning we are teleporting, and the Ray Interactor. In VR teleporting is usually represented with a curve coming out of your controller instead of the straight line that we have.

If you select the Ray Interactor, inside the inspector you will find a Raycast Configuration section.

Make sure you are changing the Teleport Raycast Configuration

Under the line type there are three in total differ options, we currently have the straight line but there are two options for curved. There is projectile curve and Bezier curve.

Projectile Curve is based on the trajectory of an imaginary that is shooting out of our controller. The Bezier Curve is a quadratic formula. For this tutorial I am going to be using the projectile, however, you should experiment with the Bezier curve to formularize yourself with it.

Selecting the projectile gives you more options for you to create the exact curve that you are wanting.

Reference Frame — The reference frame of the curve to define the ground plane and up. If not set at startup it will try to find the Rig GameObject, and if that does not exist it will use global up and origin by default.

Velocity — initial velocity of the projectile. Increase this value will make the curve reach further.

Acceleration — Gravity of the projective in the reference frame.

Additional Ground Height— Additional Height below ground level that the projectile will continue to. Increasing this value will make the end point drop lower in height.

Additional Flight Time — Additional Flight Time after the projectile lands at the adjusted ground level. Increasing this value will make the end point drop lower in height.

Sample Frequency — The number of sample points used to approximate curved paths. Larger values produce a better quality approximate at the cost of reduced performance due to the number of ray casts.

Now all that is left is to play the editor and see how the curved Raycast feels and make adjustments if needed.

I’ll see you in the next tutorial!