- Home /
Question by
Showoffz · Apr 28, 2016 at 10:16 AM ·
movementfreezeoculusoculusriftoculus rift
Stop OVRplayerController movement but allow rotation.
Hello
I am using a code that moves the OVRPLayerController.
player.GetComponent<CharacterController>().Move(direction * Time.deltaTime);
But During that I want to block OVRPlayerController from moving AND still allow rotation. Right now I have used :
playerController.enabled = false;
gamepadController.enabled = false;
But that locks also the rotation. Is there a good way of doing this? Or I will need to modify default controller files?
Comment
Best Answer
Answer by Showoffz · Apr 28, 2016 at 01:35 PM
Created a public variable inside OVRController and multiplied movement by it.
In other script changed that multiplier to 0 to freez movement and back to 1 to allow player to move again.
Pseudo code:
/// OVR CONTROLLER
int speed;
Controller.Move(moveDirection * speedM);
// Other script
player.GetComponent<OVRPlayerController>().speedM = 0;
// later...
player.GetComponent<OVRPlayerController>().speedM = 1;