Forum begins after the advertisement:
Home › Forums › Video Game Tutorial Series › Creating a Metroidvania in Unity › [Part 1] Simplifying the flipping character code
@blinkachu5275 shares the following on a YouTube comment:
for the flipping character code, you can simplify it to only 2 lines if (xAxis != 0) direction = Mathf.CeilToInt(Mathf.Sign(xAxis)); // I created a new int called direction that can only ever be -1 and 1 this way and then set my transform.localScale to be the new Vector2(direction, transform.localScale.y); Way cleaner than a whole if else if statement
if (xAxis != 0) direction = Mathf.CeilToInt(Mathf.Sign(xAxis)); // I created a new int called direction that can only ever be -1 and 1
this way and then set my transform.localScale to be the new Vector2(direction, transform.localScale.y);
Way cleaner than a whole if else if statement
Go to Login Page →
Advertisement below: