// Start is called before the first frame update public void Start() { climbers = new List <Grabber>(); characterController = GetComponentInChildren <CharacterController>(); smoothLocomotion = GetComponentInChildren <SmoothLocomotion>(); playerGravity = GetComponentInChildren <PlayerGravity>(); }
void Start() { characterController = GetComponentInChildren <CharacterController>(); mainCamera = GameObject.FindGameObjectWithTag("MainCamera").transform; if (characterController) { _initialCharacterParent = characterController.transform.parent; } _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>(); playerGravity = GetComponentInChildren <PlayerGravity>(); 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); }
void Start() { GameObject player = GameObject.FindGameObjectWithTag("Player"); if (player) { characterController = player.GetComponentInChildren <CharacterController>(); playerGravity = player.GetComponentInChildren <PlayerGravity>(); } else { Debug.Log("No player object found."); } audioSource = GetComponent <AudioSource>(); }