public void init() { // deprecated variables warnings: if (jumpForce != 0 && jumpHeight == 0) { Debug.LogError("PlayerController.jumpForce is deprecated. Use jumpHeight instead."); jumpHeight = jumpForce; } if (jumpDownwardForce != 0 && gravity == 0) { Debug.LogError("PlayerController.jumpDownwardForce is deprecated. Use gravity instead."); gravity = jumpDownwardForce; } // rigidbody should no longer use gravity, be kinematic, and freeze all constraints if (rigidbody != null) { if (rigidbody.useGravity) { Debug.LogError("The rigidbody no longer needs to use gravity. Disabling."); rigidbody.useGravity = false; } if (!rigidbody.isKinematic) { Debug.LogError("The rigidbody should be kinematic. Enabling."); rigidbody.isKinematic = true; } if (rigidbody.constraints != RigidbodyConstraints.FreezeAll) { Debug.LogError("The rigidbody should freeze all constraints. The PlayerController will take care of the physics."); rigidbody.constraints = RigidbodyConstraints.FreezeAll; } } cameraController = CameraController.instance; infiniteObjectGenerator = InfiniteObjectGenerator.instance; powerUpManager = PowerUpManager.instance; gameManager = GameManager.instance; if (attackType == AttackType.Projectile) { projectileManager = GetComponent<ProjectileManager>(); } platformLayer = 1 << LayerMask.NameToLayer("Platform"); floorLayer = 1 << LayerMask.NameToLayer("Floor"); wallLayer = LayerMask.NameToLayer("Wall"); obstacleLayer = LayerMask.NameToLayer("Obstacle"); thisTransform = transform; capsuleCollider = GetComponent<CapsuleCollider>(); playerAnimation = GetComponent<PlayerAnimation>(); playerAnimation.init(); startPosition = thisTransform.position; startRotation = thisTransform.rotation; slideData = new CoroutineData(); stumbleData = new CoroutineData(); forwardSpeeds.init(); // determine the fastest and the slowest forward speeds forwardSpeeds.getMinMaxValue(out minForwardSpeed, out maxForwardSpeed); forwardSpeedDelta = maxForwardSpeed - minForwardSpeed; if (forwardSpeedDelta == 0) { playerAnimation.setRunSpeed(1, 1); } // make sure the coin magnet trigger is deactivated activatePowerUp(PowerUpTypes.CoinMagnet, false); reset(); enabled = false; }