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);
        }
Example #2
0
        // Start is called before the first frame update
        void Start()
        {
            rotation = FindObjectOfType <PlayerRotation>();

            int turn = PlayerPrefs.GetInt("TurnSelection");

            if (turn == 0)
            {
                rotation.RotationType = RotationMechanic.Snap;
            }
            else
            {
                rotation.RotationType = RotationMechanic.Smooth;
            }
        }
Example #3
0
        // This function saves everything to playerprefs

        public void savetoPrefs()
        {
            //change rotation type
            PlayerRotation rotary = GameObject.FindGameObjectWithTag("Player").GetComponentInChildren <PlayerRotation>();

            if (turn_type == "Snap")
            {
                rotary.RotationType       = RotationMechanic.Snap;
                rotary.SnapRotationAmount = (float)rotat_angleINT;
            }
            else
            {
                rotary.RotationType       = RotationMechanic.Smooth;
                rotary.SnapRotationAmount = (float)rotat_angleINT;
            }

            //save the settings
            PlayerPrefs.SetInt("snapAngle", rotat_angleINT);
            PlayerPrefs.SetInt("TurnSelection", turn_selection);
            PlayerPrefs.SetInt("AmbLvl", amb_level);
            PlayerPrefs.SetInt("SfxLvl", sfx_level);
            PlayerPrefs.Save();
        }