🐉
Portfolio
  • Portfolio Jay Fairouz
  • Introduction Week
  • XR Concepting and Design
    • Concepting and Design Summary
    • XR Concept and iteration
    • Brown boxing
    • White boxing
    • Inspark
    • Shoeby
    • Specialisten Net
    • Walking Design
    • Multiple people in one body room
    • Environment
    • Echolocation Room
    • Portals
  • XR Assets
    • XR Assets
    • Temple Owl Logo
    • Platforms
    • Animating a moth
    • Color palette Echocave
  • XR Development
    • Development Summary
    • Dragon Race VR Development
    • Audio Visualizing
    • Walking Development
    • Glass Beads
    • Inhabit mechanic
    • Waterfall
    • Path creation
    • Learn someone how to program
    • Voice input mechanics
    • Paint
    • Portals
  • XR Testing
    • Dragon Race VR Testing
    • XR Testing
  • Group Process
    • Company Pitches
    • Sprint 1
    • Sprint 2
    • Sprint 3
    • Sprint 4
    • Sprint 5 and project conclussion
    • Project Goal
Powered by GitBook
On this page

Was this helpful?

  1. XR Development

Inhabit mechanic

PreviousGlass BeadsNextWaterfall

Last updated 3 years ago

Was this helpful?

In the previous sprint Tirso developed the inhabit mechanic for our game, however we were switching over to OpenXR and a lot of Tirso's code used built-in SteamVR systems. So I mainly had to rewrite the script, although Tirso helped quite a bit.

To summarise what I wanted to do: I basically wanted to fire a line from the player that would change in color if it hovered over an object that it could inhabit, and when it pressed a button it should inhabit the body. Inhabiting would entail gaining that body's abilities, the body I used in the gif below could walk for example.

    protected override void OnSelectEntered(SelectEnterEventArgs args)
    {
        InhabitBody(FindXRRig(args.interactor.gameObject));
        base.OnSelectEntered(args);
    }

    private GameObject FindXRRig(GameObject currentObject)
    {
        return currentObject.transform.root.GetComponentInChildren<XRRig>().gameObject;
    }

    private void InhabitBody(GameObject originalXRObject)
    {
        if (!networkPlayer) return;

        originalXRObject.SetActive(false);
        xrRig.SetActive(true);
        networkPlayer.AcquireRig();
    }