Hello, I’ll try to explain. Don’t worry about your English I’m not native either
Ternary statements don’t operate the same way an if - else if statement operates.
When you’re moving just up or down, your direction.x will be equal = 0.
Try to imagine, what happens in each version when direction.x = 0?
Teacher’s code forces the character to face right when it is moving just up or down. It can never move up or down looking to the left.
My version keeps rightLeft unchanged when direction.x = 0 so the character will keep looking to the direction it was looking at.
If direction.x = 0 then direction.x < 0 = false. (Equal to zero isn’t less than zero)
If direction.x is equal to zero, then direction.x isn’t less than zero.
If you have any more questions, I’ll be glad to help.