public void ButtonHold(GameObject gameObject) { ADSR = gameObject.GetComponent <ADSRManager>(); var Movement = ADSR.GetDirection(); gameObject.GetComponent <SpriteRenderer>().flipX = false; // if statement fixes bug that caused player to be in None state when switching directions mid-jump // Changing to the None state prevented the player from moving in the opposite direction on the same button hold if (ADSRManager.Direction.None == Movement) { ADSR.ResetTimers(); ADSR.SetPhase(ADSRManager.Phase.Attack); ADSR.SetInputDirection(Time.deltaTime); // Sets direction to know that player is moving. ADSR.SetDirection(ADSRManager.Direction.Horizontal); } ADSR = gameObject.GetComponent <ADSRManager>(); if (ADSR.getInputDirection() <= -0.7f) { ADSR.SetInputDirection(0.3f); } ADSR.SetInputDirection(Time.deltaTime); }
public void ButtonDown(GameObject gameObject) { ADSR = gameObject.GetComponent <ADSRManager>(); var Movement = ADSR.GetDirection(); if (ADSRManager.Direction.None == Movement) { ADSR.ResetTimers(); ADSR.SetPhase(ADSRManager.Phase.Attack); ADSR.SetInputDirection(-Time.deltaTime); // Sets direction to know that player is moving. ADSR.SetDirection(ADSRManager.Direction.Horizontal); } gameObject.GetComponent <SpriteRenderer>().flipX = true; }