public Vector3 RunMovement(GameObject playerHead, GameObject hand, GameObject player, SteamVR_Controller.Device controller)
        {
            // Work out where the tracked object is facing and move in that direction
            Vector2 rotation = MovementUtil.YRotationAsVector2(playerHead.transform.eulerAngles.y);

            return(new Vector3(MovementUtil.InterpolatePosition(rotation.x), 0, MovementUtil.InterpolatePosition(rotation.y)));
        }
Example #2
0
        public Vector3 RunMovement(GameObject playerHead, GameObject hand, GameObject player, SteamVR_Controller.Device controller)
        {
            // Work out where the tracked object is facing
            float currentAngleOfRotation = playerHead.transform.eulerAngles.y;
            // Find the angle between where we pressed and above
            Vector2 touchPad     = controller.GetAxis(Valve.VR.EVRButtonId.k_EButton_Axis0);
            float   anglePressed = Vector2.Angle(new Vector2(0f, 1f), touchPad);
            // Work out and apply that direction as a vector
            float   directionAngle = touchPad.x > 0 ? currentAngleOfRotation + anglePressed : currentAngleOfRotation - anglePressed;
            Vector2 movementVector = MovementUtil.YRotationAsVector2(directionAngle);

            return(new Vector3(MovementUtil.InterpolatePosition(movementVector.x), 0, MovementUtil.InterpolatePosition(movementVector.y)));
        }
 public bool IdleMovement(SteamVR_Controller.Device controller, out Vector3 position)
 {
     if (GrabPressed)
     {
         GrabPressed   = false;
         ThrowVelocity = new Vector3(-controller.velocity.x, 0f, -controller.velocity.z);
     }
     if (ThrowVelocity != Vector3.zero)
     {
         position       = new Vector3(MovementUtil.InterpolatePosition(ThrowVelocity.x), 0f, MovementUtil.InterpolatePosition(ThrowVelocity.z));
         ThrowVelocity *= FrictionMultiplier;
         return(true);
     }
     position = Vector3.zero;
     return(false);            // TODO maybe an optional like thing or restructure idle-like movement?
 }