WEEK3 | Capstone Progress [1/27 -02/02]

Pointer & Interactable Object & Loading Scenes

Yuan
4 min readJan 28, 2020

After talking with Kim on Monday(1/27) afternoon, on the very night, I started to learn how to make a Raycast in the Oculus quest.

I searched on Youtube, and finally found a good tutorial about making a raycast (pointer).

Even though this series explains everything accurately and concisely, the real understanding of every line of code he wrote came slowly.

Here are the demos of my progress from last week. what was behind the scenes were numerous deductions and experiments.

1. Creating a pointer & a responsive reticule

It might seem quite simple in the video, but there were a lot of codes behind the scene. At this point, I just went through the five tutorials in the series, got what I need, without really understand the theory.

2. Creating Interactable Objects to respond to the hovering pointer

The interactable effects that I’d first tried were changing the scale of the objects with a short sound when the pointer hovered over, which worked pretty well!

However, after I had a pointer, I did rebuild this .apk file at least 10 times (no matter Oculus rift or Oculus link for the quest, the preview feature was really not stable >_<….In this sense, Magic Leap One is greate)before I reached this point. Mostly because no matter the scale of the object or the sound, they should be changed only once after being hovered over, which needed a “flip-flop trick” I’d learned from physical computing:)

I think, at this point, I started to figure out how the messages were sent between different scripts. That’s the reason I was able to extend the contents of the original codes from the tutorial.

3. Adding the sound of triggering in the controller

To add this feature, I supposed to use “Unity Events System” to implement it. But somehow, the event of triggering the button in the controller couldn’t be sent out. Before I recap and code for the next step, I need to try it again.

4. Loading Scenes_1

The scene in the next level was loaded, but it was too quick that the sound of triggering the objects in the Main Menu was cut.

5. Loading Scenes_2

So, I added a timer to delay the loading of the scene.

6. Loading Scenes_3

Implementing the function to back to the Main Menu.

7. Loading Scenes_4

Add left controller == 20+ iterations >_<

🛠 Other Details_about “Raycast”

Beyond any doubts, using a Raycast is probably the most traditional and solid way to select items in VR. However, I’d heard people suggested me to use “stick” to replace “Raycast” several times in the past. “Oh, Raycast is complicated,” they said, “use a stick instead. The result would be the same.”

But why? I never really understood it until I finally created it.

In the real sense, a ray cast is an invisible ray that needs the information of its start point and sends out the information of its endpoint. These two pieces of information are demanded to make a visible pointer. So making a “pointer” actually is a way to materialize “Raycast”.

♦ Here is the process of building the “Pointer”:

1. Check whether the headset is mounted;

2. Check which controller is connected; if there is a controller is connected (or if both connected, get the active one), get access to the corresponding “Anchor”, getting its “transform.position”;

3. Set the position of this “Anchor” as the position of the “startPoint” of raycast;

4. Declare a variable “RaycastHit hit” to store the information from our raycast;

5. Create a “Ray ray” to get the information from its collider, and put them into “RaycastHit hit”;

6. Get the position of the “endPoint” of raycast from “hit.point” (when it hit a collider) and the setted “MaxDistance” (when it doesn’t hit anything);

7. There are two kinds of “RaycasyHit hit”, one can return info from any colliders (used for update the appearance of the pointer, which is influenced by the changing position of the “endPoint”); one only return the colliders in the “Interactable” layer (used for update the info of the colliders, which is used to change their properties);

8. With the updated position of “startPoint” and “endPoint”, from “Anchor” and “RaycastHit”, the pointer had been created.

🛠 Other Details_about “Unity Event System”

It seems that professional development with Unity would use “Unity Event System”, which would make my life much easier in the future.

I need to have a thorough understanding of it in the next week(02/03–02/09)

♦ Here is the Event System I currently have:

Next Step

1. Learning more about “Unity Event System”.

2. Refine my codes to fit into a concise Event System.

3. Add a simple “glowing” shader to interactable objects, when they’re hovered over by the pointer, and change the color of shader when triggering happens in the controller.

4. Add a short haptic effect when a hovering event happens as well as a triggering event happens.

5. Replace the placeholder cube and sphere in the scene with prototype models.

6. Try a version of 2d Menu System.

--

--

No responses yet