Search Unity

OVR PlayerPlayerController Issue - Character Controller Mistakenly Rotates Around Prefab's Pivot

Discussion in 'VR' started by bmoodyP3, Jul 23, 2019.

  1. bmoodyP3

    bmoodyP3

    Joined:
    Jul 23, 2019
    Posts:
    12
    BACKGROUND:


    I am crafting a PlayerPrefab for a VR application I am building. This prefab has the ability to move forward/back and left/right via the left Touch joystick and can snap-rotate via the right Touch joystick.


    However, when I press the rotate button, my entire character controller is rotated around the player prefab pivot instead of its own pivot. The second pair of photos illustrates this.


    This is a complex prefab and has considerable logic on it. (It was given to me by another developer.)


    Before I rebuild it from scratch, is there an easy way that I can fix this issue?


    EXPECTED BEHAVIOR:


    When I press rotate, my position does not change at all.


    ACTUAL BEHAVIOR:


    When I am far from my character controller and I rotate, I rotate around the pivot of the PlayerPrefab rather than the pivot of the Character Controller.

    Rotating when I am near the Player Prefab's Pivot:

    upload_2019-7-22_17-1-22.png

    upload_2019-7-22_17-1-29.png




    Rotating when I am NOT near the Player Prefab's Pivot:

    upload_2019-7-22_17-0-13.png

    upload_2019-7-22_17-0-27.png


    My Hierarchy:


    upload_2019-7-22_17-0-58.png


    I also have the following script on my OVRCameraRig:


    using System.Collections;

    using System.Collections.Generic;

    using UnityEngine;


    public class VRCameraCharacterControllerFix : MonoBehaviour

    {


    public CharacterController character;

    public GameObject centerEyeAnchor;

    private Vector3 place;

    void FixedUpdate()

    {

    place = new Vector3(centerEyeAnchor.transform.localPosition.x, 0, centerEyeAnchor.transform.localPosition.z);


    character.center = place;



    }

    }