Ejemplo n.º 1
0
        bool requiresReparent; // Should we reparent the player after we hop off?

        void Start()
        {
            smoothLocomotion    = GetComponentInChildren <SmoothLocomotion>();
            characterController = GetComponentInChildren <CharacterController>();

            _initialCharacterParent = transform.parent;
        }
Ejemplo n.º 2
0
 // Start is called before the first frame update
 public void Start()
 {
     climbers            = new List <Grabber>();
     characterController = GetComponentInChildren <CharacterController>();
     smoothLocomotion    = GetComponentInChildren <SmoothLocomotion>();
     playerGravity       = GetComponentInChildren <PlayerGravity>();
 }
Ejemplo n.º 3
0
        void Start()
        {
            mainCameraTransform = GameObject.Find("CameraRig").transform;
            leftHandAnchor      = GameObject.Find("LeftHandAnchor").transform;
            rightHandAnchor     = GameObject.Find("RightHandAnchor").transform;

            leftControllerTranform  = GameObject.Find("LeftControllerAnchor").transform;
            rightControllerTranform = GameObject.Find("RightControllerAnchor").transform;

            player = FindObjectOfType <BNGPlayerController>();

            if (player)
            {
                // Use this to keep our head up high
                player.ElevateCameraIfNoHMDPresent = true;
                _originalPlayerYOffset             = player.ElevateCameraHeight;

                smoothLocomotion = player.GetComponentInChildren <SmoothLocomotion>();

                if (smoothLocomotion == null)
                {
                    Debug.Log("No Smooth Locomotion component found. Will not be able to use SmoothLocomotion without calling it manually.");
                }
                else if (smoothLocomotion.MoveAction == null)
                {
                    Debug.Log("Smooth Locomotion Move Action has not been assigned. Make sure to assign this in the inspector if you want to be able to move around using the VR Emulator.");
                }
            }
        }
Ejemplo n.º 4
0
        void Start()
        {
            characterController = GetComponent <CharacterController>();
            smoothLocomotion    = GetComponentInChildren <SmoothLocomotion>();
            playerRigidbody     = GetComponent <Rigidbody>();

            _validRigidBody = playerRigidbody != null;

            _initialGravityModifier = Gravity;
        }
Ejemplo n.º 5
0
        void Start()
        {
            characterController = GetComponentInChildren <CharacterController>();
            mainCamera          = Camera.main.transform;

            if (characterController)
            {
                _initialCharacterParent = characterController.transform.parent;
            }

            _initialGravityModifier = GravityAmount;

            _initialPosition = characterController.transform.position;
            float initialY = _initialPosition.y;

            if (initialY < MinElevation)
            {
                Debug.LogWarning("Initial Starting Position is lower than Minimum Elevation. Increasing Min Elevation to " + MinElevation);
                MinElevation = initialY;
            }
            if (initialY > MaxElevation)
            {
                Debug.LogWarning("Initial Starting Position is greater than Maximum Elevation. Reducing Max Elevation to " + MaxElevation);
                MaxElevation = initialY;
            }

            teleport         = GetComponent <PlayerTeleport>();
            smoothLocomotion = GetComponentInChildren <SmoothLocomotion>();
            playerRotation   = GetComponentInChildren <PlayerRotation>();

            climbers = new List <Grabber>();

            // Player root must be at 0,0,0 for Tracking Space to work properly.
            // If this player transform was moved in the editor on load, we can fix it by moving the CharacterController to the position
            if (transform.position != Vector3.zero || transform.localEulerAngles != Vector3.zero)
            {
                Vector3    playerPos = transform.position;
                Quaternion playerRot = transform.rotation;

                transform.position = Vector3.zero;
                transform.rotation = Quaternion.identity;

                if (characterController)
                {
                    characterController.transform.position = playerPos;
                    characterController.transform.rotation = playerRot;
                }

                Debug.Log("Player position not set to 0. Moving player to : " + playerPos);
            }

            ChangeLocomotionType(selectedLocomotion);
        }
Ejemplo n.º 6
0
        void Start()
        {
            mainCameraTransform     = GameObject.Find("CameraRig").transform;
            leftControllerTranform  = GameObject.Find("LeftHandAnchor").transform;
            rightControllerTranform = GameObject.Find("RightHandAnchor").transform;

            player = FindObjectOfType <BNGPlayerController>();

            // Use this to keep our head up high
            player.ElevateCameraIfNoHMDPresent = true;
            _originalPlayerYOffset             = player.ElevateCameraHeight;

            smoothLocomotion = player.GetComponentInChildren <SmoothLocomotion>();
        }
Ejemplo n.º 7
0
        void Start()
        {
            if (GameObject.Find("CameraRig"))
            {
                mainCameraTransform = GameObject.Find("CameraRig").transform;
            }
            // Oculus Rig Setup
            else if (GameObject.Find("OVRCameraRig"))
            {
                mainCameraTransform = GameObject.Find("OVRCameraRig").transform;
            }

            leftHandAnchor  = GameObject.Find("LeftHandAnchor").transform;
            rightHandAnchor = GameObject.Find("RightHandAnchor").transform;

            leftControllerTranform  = GameObject.Find("LeftControllerAnchor").transform;
            rightControllerTranform = GameObject.Find("RightControllerAnchor").transform;

            player = FindObjectOfType <BNGPlayerController>();

            if (player)
            {
                // Use this to keep our head up high
                player.ElevateCameraIfNoHMDPresent = true;
                _originalPlayerYOffset             = player.ElevateCameraHeight;

                smoothLocomotion = player.GetComponentInChildren <SmoothLocomotion>(true);

                // initialize component if it's currently disabled
                if (smoothLocomotion != null && !smoothLocomotion.isActiveAndEnabled)
                {
                    smoothLocomotion.CheckControllerReferences();
                }

                playerTeleport = player.GetComponentInChildren <PlayerTeleport>(true);
                if (playerTeleport)
                {
                    priorStraightSetting = playerTeleport.ForceStraightArrow;
                }

                if (smoothLocomotion == null)
                {
                    Debug.Log("No Smooth Locomotion component found. Will not be able to use SmoothLocomotion without calling it manually.");
                }
                else if (smoothLocomotion.MoveAction == null)
                {
                    Debug.Log("Smooth Locomotion Move Action has not been assigned. Make sure to assign this in the inspector if you want to be able to move around using the VR Emulator.");
                }
            }
        }
Ejemplo n.º 8
0
        void Start()
        {
            GameObject player = GameObject.FindGameObjectWithTag("Player");

            if (player)
            {
                characterController = player.GetComponentInChildren <CharacterController>();
                playerGravity       = player.GetComponentInChildren <PlayerGravity>();
                smoothLocomotion    = player.GetComponentInChildren <SmoothLocomotion>();
            }
            else
            {
                Debug.Log("No player object found.");
            }

            audioSource = GetComponent <AudioSource>();
        }
Ejemplo n.º 9
0
        public void ChangeLocomotionType(LocomotionType loc)
        {
            // Make sure Smooth Locomotion is available
            if (smoothLocomotion == null)
            {
                smoothLocomotion = GetComponent <SmoothLocomotion>();
            }

            selectedLocomotion = loc;

            if (teleport == null)
            {
                teleport = GetComponent <PlayerTeleport>();
            }

            toggleTeleport(selectedLocomotion == LocomotionType.Teleport);
            toggleSmoothLocomotion(selectedLocomotion == LocomotionType.SmoothLocomotion);
        }
Ejemplo n.º 10
0
        void Start()
        {
            characterController = GetComponentInChildren <CharacterController>();
            smoothLocomotion    = GetComponentInChildren <SmoothLocomotion>();

            mainCamera = GameObject.FindGameObjectWithTag("MainCamera").transform;

            if (characterController)
            {
                _initialPosition = characterController.transform.position;
            }
            else
            {
                _initialPosition = transform.position;
            }

            playerClimbing = GetComponentInChildren <PlayerClimbing>();
        }