// IdleState = Animator.StringToHash("Base Layer.Idle"); protected virtual void Idle(float elapsedTime) { // Switch between crouching and standing idles based off enemies that could hear float idleNum = MecanimAnimator.GetFloat(MecanimHashes.IdleNum); float targetIdle = GameManager.AI.EnemiesCouldHear > 0 ? 1 : 0; idleNum = Mathf.Lerp(idleNum, targetIdle, elapsedTime * IdleChangeSpeed); MecanimAnimator.SetFloat(MecanimHashes.IdleNum, idleNum); // You can start moving left or right at any point ApplyMovingHorizontal(elapsedTime); ApplyBiDirection(); // You stick to the ground VerticalSpeed = GroundVerticalSpeed; MecanimAnimator.SetFloat(MecanimHashes.VerticalSpeed, VerticalSpeed); // You could potentially fall down if the ground disappears beneath you MecanimAnimator.SetBool(MecanimHashes.Fall, !IsGrounded); // You can only pickup items while in idle if (CharInput.Pickup) { GameObject itemObj = null; bool canPickup = CanPickupItem(out itemObj); if (canPickup && itemObj != null) { _itemPickedup = itemObj.GetComponent <Item>(); } MecanimAnimator.SetBool(MecanimHashes.Pickup, canPickup && _itemPickedup != null); } // You can re-grab ropes you just let go of bool shouldRegrabRope = CharInput.Up && PreviousHangTarget != null && PreviousHangTarget.GetComponent <Collider>().bounds.Contains(transform.position); if (shouldRegrabRope) { AddHangTarget(PreviousHangTarget); MecanimAnimator.SetBool(MecanimHashes.ClimbRope, true); } // You can jump AllowGroundJump(); }