Jump to content
 
Fangh

[Unity3D SDK] How to teleport player ?

Recommended Posts

Hello.

I can see that in the Unreal SDK there is a teleport method but I can't find one in the Unity3D SDK.

image.png.a835cc872e65c5b7bfe759275d3cd49c.png

When I try to move the "head" object, it doesn't work, it goes back to it previous position. I think this is because I can't move the head of the player, it seems normal.

When I try to move the "WaveVR" object, it works but it move the "play area" not the player. 

Example :

  1. Let's say X is my origin, where the player start
  2. My player move 1m to the right (X+1)
  3. Then the player point with its controller somewhere in the scene, let's call this point P.
  4. Then the player push a button of its controller. At that time I do something like WaveVR.position = P.position
  5. My player is now 1m to the right of P (P+1). Not P.

 

What can I do ?

Thank you

 

@Tony PH Lin

Share this post


Link to post
Share on other sites

Hi @Fangh

The idea moving "WaveVR" object is correct. But you'll need to calculate and handle the offset. Below is sample code for your reference. "head" here in the code snippet represents to WaveVR_Render.Instance.gameObject

        protected override bool Teleport (Vector3 position)
        {
            if (head == null)
                return false;

            Vector3 head_position = head.transform.localPosition;

            currentTargetPosition.x = position.x - head_position.x;
            currentTargetPosition.y = position.y;
            currentTargetPosition.z = position.z - head_position.z;

            return true;
        }

Then you'll be able to do teleport in Unity by applying the calculated currentTargetPosition to WaveVR.transform.localPosition,.

Share this post


Link to post
Share on other sites

Please sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...