// Update gets called every frame void Update() { // Moving with the arrow keys if (typeOfControl == Enums.KeyGroups.ArrowKeys) { moveHorizontal = Input.GetAxis("Horizontal"); moveVertical = Input.GetAxis("Vertical"); } else { moveHorizontal = Input.GetAxis("Horizontal2"); moveVertical = Input.GetAxis("Vertical2"); } //zero-out the axes that are not needed, if the movement is constrained switch (movementType) { case Enums.MovementType.OnlyHorizontal: moveVertical = 0f; break; case Enums.MovementType.OnlyVertical: moveHorizontal = 0f; break; } if (jump != null) { if (!canMoveInAir) { bool isOnGround = jump.CanJump(); Debug.Log(isOnGround); if (!isOnGround) { movement = Vector2.zero; } else { movement = new Vector2(moveHorizontal, moveVertical); } } else { movement = new Vector2(moveHorizontal, moveVertical); } } else { movement = new Vector2(moveHorizontal, moveVertical); } //rotate the GameObject towards the direction of movement //the axis to look can be decided with the "axis" variable if (orientToDirection) { if (movement.sqrMagnitude >= 0.01f) { cachedDirection = movement; } Utils.SetAxisTowards(lookAxis, transform, cachedDirection); } }