[Suggestion] Character can only face right when moving up or down

Teacher’s code is as follows:

direction.x < 0.f ? rightLeft = -1.f : rightLeft = 1.f;

However this makes the character always face right when you’re moving only up or down.
To fix it I used:

if (direction.x < 0.f) {rightLeft = -1.f;}
else if( direction.x > 0.f) {rightLeft = 1.f;}

A minor incovenience but small details can make a big difference.

Privacy & Terms