🐉
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
  • Portal
  • Minor adjustments
  • Final result

Was this helpful?

  1. XR Development

Portals

I wanted to make a portal that teleports the player to another portal upon collision. A portal is either for souls or for inhabited bodies and only becomes visible if the player is in the correct state. The portals will get their visual looks by a shader that Tirso has written.

Portal

The first thing that I needed to do was track if the player was a soul or if they had inhabited a body. I wrote a script that kept track of the players' states.

public class PlayerData : MonoBehaviour
{
    public bool isSoul;
    public bool inRoom;
}

I used that state in the Portal script to determine if the player could teleport. A soul can go through a soul portal and an inhabited body can go through non-soul portals. In the TeleportPlayer function I position and rotate the player to a spawnPosition gameObject, which is a child of the portal that the player needs to teleport to. I had a bit of help with calculating the rotations from Tirso.

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Player"))
        {
            PlayerData playerData = other.gameObject.GetComponent<PlayerData>();
            if (playerData)
            {
                if (soulPortal)
                {
                    if (playerData.isSoul)
                        TeleportPlayer(other.gameObject, playerData);
                }
                else
                {
                    if (!playerData.isSoul)
                        TeleportPlayer(other.gameObject, playerData);
                }
            }
        }
    }

    private void TeleportPlayer(GameObject player, PlayerData playerData)
    {
        player.transform.position = linkedPortalSpawnPosition.position;
        playerData.inRoom = !playerData.inRoom;
        player.transform.localRotation = Quaternion.Euler(0, linkedPortalSpawnPosition.localEulerAngles.y - player.GetComponentInChildren<Camera>().transform.localEulerAngles.y, 0);
    }

This solution caused me to have to set up each spawnPosition rotation mannualy, which was quite bothersome because I had to test it in VR take the headset off change some variables and see if the rotation was correct. I had to do that for a total of 6 portals, so that took a bit of time. It was a better solution than calculating the rotation based on the player forward, because the player rotations were set up quite badly. There were multiple child objects in the player that had different rotations, which made it quite difficult to calculate.

Minor adjustments

With the addition of the portals, there was no reason anymore for the player to be able to exit every room with the press of a button. Previously you could press the B button and leave your inhabited body and you would be teleported to the position where you inhabited the body. I changed it so you can only exit a body when you're inside of the HUB.

    public void ExitBody(InputAction.CallbackContext obj)
    {
        if (!playerData.inRoom)
        {

Final result

This is how the portal effect looked, without the Tirso's shader on it while entering the echolocation room.

And here is how it looks with the shader:

PreviousPaintNextDragon Race VR Testing

Last updated 3 years ago

Was this helpful?