Search Unity

Can Someone please explain to me how this works?

Discussion in '2D' started by BigBen268, Feb 10, 2019.

  1. BigBen268

    BigBen268

    Joined:
    Nov 25, 2018
    Posts:
    2
    Hello , the code is fully functional I'm just wondering how it all ties together and all. Especially how the scaling works for the sprite flip I have set up. Thanks :)
     

    Attached Files:

  2. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    Code (csharp):
    1. if(moveHorizontal > 0 && !facingRight || moveHorizontal < 0 && facingRight) {
    Are you sure it works?
     
  3. BigBen268

    BigBen268

    Joined:
    Nov 25, 2018
    Posts:
    2
    Yes I am
     
  4. drcrck

    drcrck

    Joined:
    May 23, 2017
    Posts:
    328
    Yeah actually I recalled && takes precedence over ||
    Though I'd never write a condition like this without brackets