XRD Week 7
Repository link: https://github.com/SchlagerSoftware/KeeperVR
XRD Week 7
This week we focused on putting all the elements together. We started with the start menu where the player has the option to start the game, stop and change the volume. Adding the TrackedDeviceGraphicRaycaster to the canvas placed in worldspace made it possible to respond to the XRRayIntercator located in the controllers. Thanks to this, when targeting the button, users can see the color change of the laser and are able to perform a click event on it, and in the case of a slider, they are able to grab it and drag it. In the menu, we dropped the LocomotionSystem as this scene does not contain any additional functionality.
In the next step, we made a decision to change the way of saves. In this regard, we decided that the user should catch the ball with the controllers, and not just come into a physical collision with the character controller or with his hands. To achieve this, we pinned the XRGrabInteractable component to the ball as Instantaneous, because in our case the ball does not affect other elements after being caught, and the most important thing is the time and moment of catching the ball (as little delay as possible). In addition, we also shortened the raycast distance and the length of the lasers for the controllers, so that the collision with the ball was only detectable at short distances.
To the functionalities prepared in this way, the only thing left was to add a start button, reset button and a scoreboard. The buttons have been implemented exactly in the same way as those in the menu, only the logic changes after they are called. After clicking on the start of the game, the referee's whistle sounds, and after a few seconds the ball "kicks" in a random direction. Reset is responsible for bringing the ball back to its starting position. A goal appears on the scoreboard when the ball collides with the invisible line and the ball returns to its starting position. We thought about how to implement defense detection for a long time. Ultimately, by changing the approach and adding the catching functionality, we were able to listen to the SelectEnter and SelectExited events provided by the XRGrabInteractable. When we catch the ball, we know that there has been a save and we add a point. When the player leaves the ball, we reset its position and display the start button again.
This is what our first VR project looks like. During its development, we explored many secrets of the approach and programming techniques of VR applications such as mechanisms, components and scripts built into the XRInteraction Toolkit, thanks to which the entire process becomes very pleasant and transparent. We spent the most time on the locomotion system and the way the ray interactor and the input system works. Although it is not very difficult to implement, it takes some time to get familiar with it.
Author: Przemyslaw Kozik
Comments
Post a Comment