How to teleport to custom point with Oculus Locomotion Controller?
Asked Answered
P

3

1

I am trying to teleport the player on top of a tower when pressing a button. In Unity it works fine, however on the Oculus Quest the player is only in the right position for one frame and then gets moved down.

Sometimes (I cant reproduce this) the player actually gets teleported correctly. Normal teleporting by using the "Teleport Aim Handler Parabolic" included in the "Oculus Integration" works fine.

I tried to simply move the PlayerController. I tried to move the destination marker by script to the target before teleporting. I tried to move the player via LocomotionTeleport.DoTeleport() and then raise the players position.

All of the ways I tried worked in the Editor, but on the Quest the player is only on the correct position for one frame, before the y gets changed (normaly to whatever it was before the teleportation).

Pinnatifid answered 16/7, 2019 at 16:29 Comment(0)
C
1

Found even simpler solution, just disable OVRPlayerController while updating the position, no need to do delays:

public class MoveObjectBySpace : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            var player = GetComponentInChildren<OVRPlayerController>();
            player.enabled = false;
            transform.position = new Vector3(Random.Range(-5, 5), transform.position.y, Random.Range(-5, 5));
            player.enabled = true;
        }
    }
}
Chlorate answered 17/6, 2020 at 7:40 Comment(1)
Thank you! It works like a charm. Spent couple of hours trying to resolve this issue..Surveyor
P
0

I found a way to do this. The problem arises from "OVRPlayerController". By deactivating it for half a second before teleporting up to the top of the tower teleporting works. I am sure there is a better way to do this but it works as a start.

Pinnatifid answered 22/7, 2019 at 8:16 Comment(0)
G
0

I am into the same situation as yours. As you said in your answer, it works. However, when the HMD moves from its starting position (Person wears the headset walks a little bit, which in turn moves the OVRPlayerController as well as the camera rig in 3D space) and then when you do the teleport to the top floor, it is not teleporting to the exact position. It adds the OVRPlayerController's current position to the teleport position. Sometimes it goes off the floor and the player falls down.

My hierarchy is

Parent - >Player
 Child -> OVRPlayerController
 Child of child - > CameraRig

My script is as given below,

 void Update(){
     oVRPlayerController.GetComponent<CharacterController>().enabled = isPlayerActive;
    if (recenter)
    {

         oVRPlayerController.localPosition = new Vector3(0, oVRPlayerController.localPosition.y, 0);
        cameraRig.localPosition = new Vector3(0, cameraRig.localPosition.y, 0);
        recenter = false;            
    }
}

 public void HomeTeleport() //Assign this in the menu button.
{
    isPlayerActive = false;
    Invoke("TeleToTop", 0.5f);
}


 public void TeleToTop()
{
    player.position = TopPosition;
    player.rotation = TopRotation;
    isPlayerActive = true;
    recenter = true;
}

I suspect the Parent Player empty gameobject for this offset issue. Have you directly changed the OVRPlayerControllers position to the teleport point?

Gallicanism answered 28/9, 2019 at 2:32 Comment(1)
and I found something in OVRPlayerController.cs.// This event is raised right before the character controller is actually moved in order to provide other systems the opportunity to move the character controller in response to things other than user input, such as movement of the HMD. See CharacterCameraConstraint.cs for an example of this. public event Action PreCharacterMove; How do we use this?\Gallicanism

© 2022 - 2024 — McMap. All rights reserved.