Reputation: 91
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).
Upvotes: 1
Views: 3318
Reputation: 11722
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;
}
}
}
Upvotes: 1
Reputation: 13
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?
Upvotes: 0
Reputation: 91
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.
Upvotes: 0