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).

3 Answers 3

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;
        }
    }
}
1
  • 1
    Thank you! It works like a charm. Spent couple of hours trying to resolve this issue.. Jan 29, 2021 at 5:51
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.

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?

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?\
    – Vikneshtk
    Sep 28, 2019 at 2:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.