diff --git a/CharacterController2D.cs b/CharacterController2D.cs index 925bfe0..a7c193d 100644 --- a/CharacterController2D.cs +++ b/CharacterController2D.cs @@ -16,6 +16,7 @@ public class CharacterController2D : MonoBehaviour private bool m_Grounded; // Whether or not the player is grounded. const float k_CeilingRadius = .2f; // Radius of the overlap circle to determine if the player can stand up private Rigidbody2D m_Rigidbody2D; + private SpriteRenderer m_spriteRenderer; private bool m_FacingRight = true; // For determining which way the player is currently facing. private Vector3 m_Velocity = Vector3.zero; @@ -33,7 +34,7 @@ public class BoolEvent : UnityEvent { } private void Awake() { m_Rigidbody2D = GetComponent(); - + m_spriteRenderer = GetComponent(); if (OnLandEvent == null) OnLandEvent = new UnityEvent(); @@ -135,12 +136,7 @@ public void Move(float move, bool crouch, bool jump) private void Flip() { - // Switch the way the player is labelled as facing. m_FacingRight = !m_FacingRight; - - // Multiply the player's x local scale by -1. - Vector3 theScale = transform.localScale; - theScale.x *= -1; - transform.localScale = theScale; + m_spriteRenderer.flipX= !m_FacingRight; } }