ShurikenVR Devlog#3: Locomotion – Teleportation Kunai

Until now, I’ve been using the default movement control provided by XR Interaction Toolkit. However, I would like to reserve the thumbsticks for weapon selection in the future (like Space Pirate Trainer) and limit user movement to only teleportation. The default ray-interacted teleportation system provided by the XR Interaction toolkit is easy to use, but it’s not what I wanted. I mentioned in Devlog#0 that I wanted to use a projectile (a kunai) to teleport.

After some digging in the code from XR Interaction Toolkit, I found out that I can reuse the LocomotionSystem and TeleportationProvider. Instead of using the XRRayInteractor and BaseTeleportationInteractable, I can shoot a projectile and queue a teleportation request when it hit something:

TeleportationProvider tp = player.GetComponent<TeleportationProvider>();
if (tp != null)
    tp.QueueTeleportRequest(new TeleportRequest
        requestTime = Time.time,
        matchOrientation = MatchOrientation.WorldSpaceUp,
        destinationPosition = transform.position,
        destinationRotation = player.transform.rotation

To shoot the teleportation kunai, the player will need to hold down primary button, aim and let go to shoot. I’ve added a LineRenderer to trace out the path the kunai will travel, to help with aiming.

To make it more fancy, a “rune paper” is added to the end of the kunai, with cloth simulation and gravity enabled. When the kunai hits, an upward force will be applied to the rune paper and it’ll play a dissolve effect (tutorial from Brackeys).

To restrict the player from shooting multiple kunai at once, I decided to add a cooldown / charge system (similar to Hyperdash) and only allow one hand to use teleport at a time.

Leave a Comment

Your email address will not be published. Required fields are marked *