Hi everyone!
When working on flipping the sprite in this course I found 2 sollutions that seem to work in this case. I searched a bit online as to why use one over the other and I thought I’d share it here
Option 1:
I have seen this option a few times and for me it looked more ‘usefull’ than to scale the object.
BUT! There is a reason why you should NOT do this!
When working with child sprites, they also get flipped which could result in weird outputs!
Read this post about this on the Unity forum for a good example:
https://forum.unity.com/threads/flip-x-or-scale-x.1042324/
Option 2
Ofcourse option 2 being the way that is shown in the course itself using scaling instead of actually flipping the sprite! In the link above is also explained why this is better in some cases
Here I just want to show a more ‘compact’ way of writing the code. For if anyone doesn’t like all those brackets all over the place
NOTE: this way of writing if statements ONLY works if the code to be executed consists of only 1 line!
If you break up the code after the ‘if’ condition on multiple lines then only the FIRST line will run. In that case you DO need brackets to ‘group’ the code you want to have run when the condition evaluates to ‘true’
Hope this is of any use to anyone!