HOW TO FLIP YOUR SPRITE IN UNITY 🎮 | Flip Your Player In Unity | Unity Tutorial

Поділитися
Вставка
  • Опубліковано 20 вер 2024

КОМЕНТАРІ • 84

  • @نواف-ش8س3ه
    @نواف-ش8س3ه 6 місяців тому +1

    Bro i don`t know how to thank you ! you saved my life in the minute 3:58 when you said that Vector come by default float so you must put (f) after each number or he will think it`s double, i have sarch for days for this problem (Cannot Convert Argument from Double to a float) and i just fixed it, Thank you 3>

  • @mintydog06
    @mintydog06 2 роки тому +2

    Thanks. The advice at the start was also help, about how to improve play performance simply by clicking on the scene so that there isnt a lot of things in the inspector. I never knew that.

  • @SilverCat75
    @SilverCat75 9 місяців тому +1

    you're a fricken lifesaver!!! thanks so much for these tutorials! I've actually learned so much just through you stuff!

  • @autolearn738
    @autolearn738 Рік тому

    Im so glad to see this solution I tried to resolve for 3 days, you have one fallower more. Thanks a lot. You are the best teacher. 👏❤

  • @LSPTaris
    @LSPTaris Рік тому +4

    Thank you so much ! Could not get the child objects to flip with the character until using this !

  • @ChapCanai
    @ChapCanai Рік тому +1

    Thanks, your method also worked for other scales instead of having to be fixed at 1

  • @buildworldswithme
    @buildworldswithme 2 роки тому

    Seen this video. Thought to myself "You HAVE to subscribe to this dude"
    Only to come here and find out I already subscribed long ago.

  • @cozmo_Comet
    @cozmo_Comet 6 місяців тому

    Its crazy how one small error can cause something to not work lol, anyway this helped me find my issue. Thanks!

  • @ITYWTD_
    @ITYWTD_ 3 місяці тому

    Learning to create custom animations for my games, thanks!

  • @der_timon7024
    @der_timon7024 2 роки тому +5

    Thanks, helped me a lot

  • @shuffle8
    @shuffle8 2 роки тому +1

    Thank you this is super straightforward!

  • @akithemacaw8212
    @akithemacaw8212 Рік тому +3

    Perfect tutorial, unless your character isn't scaled to 1, 1, 1. My scaling is too small for it to work, even if I put in the right numbers

  • @Stoney_Eagle
    @Stoney_Eagle 2 роки тому +2

    What if you create a feature on your website where you have keywords that finds videos and gives you a timestamp where that subject is explained?
    This would work for every tutorial you've made 😉
    And if you do some awesome SEO you'll gain a ton of external views too.

  • @Manuella15
    @Manuella15 Рік тому +1

    Thanks a lot for the tutorial!

  • @der_timon7024
    @der_timon7024 2 роки тому +4

    Could you pls do a Tutorial for rotating the player in the direction he moves. (top down 2D)

  • @loutherobot
    @loutherobot 20 днів тому

    my player keeps getting fat whenever I move😭 what did I do wrong?
    nevermind I fixed it 👍 great vid!

  • @f3rnando065
    @f3rnando065 5 місяців тому +1

    thanks a lot

  • @xyznikk
    @xyznikk 2 роки тому +2

    Interesting Video!

  • @roberttrottini9660
    @roberttrottini9660 Рік тому +2

    I’m having an issue where my pivot point isn’t centered and when the character flips, it moves along a pivot that I don’t want. Is there a way to move the pivot point to be equal to the center point?

  • @bossfakealeks12345
    @bossfakealeks12345 Рік тому

    Thank you, very well and good explained

  • @javazombi
    @javazombi Рік тому

    Thanks! This got me untuck in minutes.

  • @Uc.urielco
    @Uc.urielco 6 днів тому

    Hi, I'm a newbie and curious why didn't you use the component Sprite Renderer by Flip-Y ?

  • @GamingGables
    @GamingGables Рік тому +3

    Hi Dani! I am having an issue when adding animation. When I move left, the "walk_face_right" animation still plays. When I stop, my character sprite flips to face left. Before adding this code my "walk_face_left" animation worked. Do you have any suggestions? Thank you for this awesome tutorial!

  • @BlazingFunk
    @BlazingFunk Рік тому

    Thanks that was what I looked for.

  • @mabiii4817
    @mabiii4817 Рік тому

    Thanks you very much! nice tutorial!

  • @mohamedalmatter9073
    @mohamedalmatter9073 2 роки тому +1

    he making flip when i jump and go left or right but when i go right or left its not flip

  • @TheTrickyify
    @TheTrickyify Рік тому +1

    Edit: This is easier for me in the way that I understand it better, it is just that you won´t be able to call this function if you would like to flip the character in another scenario like for a cutscene or such :)
    I made a bit easier method of the good solution for this, just as he did, create a float inputHorizontal and bool facingRight = true in the beginning of the public class PlayerController. Then make the function FixedUpdate() and in there get the horizontal as shown but in the if statements keep it as the "bad example" just add in the if statement of facing right with inputHorizontal > 0 && facingRight == false and the left inputHorizontal < 0 && facingRight == true and inside add the gameobject rnasform as shown but also in the right one you set facingRight = true; and in the left one you set facingRight = false; Less code and it only runs when flipping the other way. Hope this made sense

    • @Dani_Krossing
      @Dani_Krossing  Рік тому +1

      From what you describe, if I’m understanding it correctly, the only difference is that you are doing the same exact same thing as my “good example”, but without using a separate method. 🙂
      Also, the part in Flip() with the “facingRight = !facingRight”, does the exact same thing as setting “facingRight = false” and “facingRight = true”.
      So what you are describing is the same as my last example, but combining the Flip() method directly into FixedUpdate(). 🙂
      Your way is definitely a valid way to do it. 😊 However it is less reusable if you at some point need to flip the character, for some other reason. Since you would have to re-write the code again.

    • @TheTrickyify
      @TheTrickyify Рік тому

      @@Dani_Krossing Ah I see, that makes sense. I am using a 2d controller that was already made that I liked for my game so I am adding to that script, so your good way didn´t really work for me and I didn´t understand how it worked so I came up with it like this so it made sense to me but if I would need to face my character in another direction for any reason I have this video to go back too!
      Thanks alot :D

  • @ObitoUchiha-zu9yn
    @ObitoUchiha-zu9yn 5 місяців тому

    Thanks

  • @NHZC
    @NHZC 10 місяців тому

    Thanks for the video great help. Also on an unrelated note are you related to Elon Musk? the similarities are uncanny

  • @marcosantos9512
    @marcosantos9512 2 роки тому

    Thank you so much man!

  • @reystation4570
    @reystation4570 5 місяців тому +1

    For Godot users: This can also be applied in Godot.

  • @Surzom
    @Surzom 2 роки тому

    thank you so much, subbed

  • @RanilSuper
    @RanilSuper Рік тому

    Thanks you!

  • @lukegreenelsh4456
    @lukegreenelsh4456 2 роки тому +3

    The Elon Musk of game design. Nailed it, thanks.

    • @archsteel7
      @archsteel7 2 роки тому +9

      Don't insult them like that

    • @van641
      @van641 Рік тому

      elon musk is a dumbass why would you even compare the two lmao 😭

  • @Gr3asY
    @Gr3asY 5 місяців тому

    Thank you, saved so much time🙏

  • @vikaskumar-lr4cn
    @vikaskumar-lr4cn 2 роки тому +1

    Hello,
    I have made a car wheel in blender and baked normal map highpoly to lowpoly it's looks good in blender but when I import in unity normal map doesn't looks good as looks in blender what could be issue.
    And what is the better way to make normal map in blender for unity or other game engines

  • @TheAnimatedSquare
    @TheAnimatedSquare Місяць тому

    A bit late, but I have a question.
    I’m trying this method, and it works, but whenever you stand still, it believes you are above and below or something, and flips the player rapidly every frame, is there a way to fix this?

  • @HienLe-lf2xc
    @HienLe-lf2xc Рік тому

    I like your hair 😆😆

  • @HUSEYINBERIK
    @HUSEYINBERIK 9 місяців тому

    Hi Dani my character slides quick of he side either direction and carries on moving ? what could be the issue?

  • @snowballzyt
    @snowballzyt Рік тому

    How can we make it follow the mouse? Like flip when mouse is on the left or right.

  • @reploidzero9058
    @reploidzero9058 Рік тому

    can someone help me? i copied your movement script and my guy slides around like hes on ice? how do i prevent this?

  • @pkuuuu
    @pkuuuu Рік тому

    Hey, stupid question. Why do we need to delcare gameobject.trasnform.localSclae = currentScale again?

  • @baseddino
    @baseddino 2 роки тому

    thanks this wasn't in the 2d character movement video

  • @michi8050
    @michi8050 Рік тому

    but how about up and down?

  • @Pixeleyesd
    @Pixeleyesd 6 місяців тому

    how do you add jump?

  • @darkernessto9229
    @darkernessto9229 Рік тому

    I cant flip my character XoX .help ,please....

  • @ItsAkile
    @ItsAkile 2 роки тому

    Tried a few methods but the Left movement constantly jitters my animation < > < >, the right side gets stuck right but sometime flip facing left while moving right . is it something to do with the animations

    • @Dani_Krossing
      @Dani_Krossing  2 роки тому

      That issue happens when your player flips twice in one direction, and not in the other. It is most likely because your "flip check" when you move, is set incorrectly. :) Happens to me some times too hehe.

    • @sabfinlay-smith5773
      @sabfinlay-smith5773 Рік тому

      @@Dani_Krossing I'm having this issue too! first time coder :') what's a flip check and how can I go about correcting it? I followed your code to a T but can't see any errors!

  • @irinidanavasi1666
    @irinidanavasi1666 2 роки тому +1

    How do i fix: 《Transform does not contain a definition for localscale and no accessible extension method localscale accepting a first argument of type transform could be found》?

    • @doubleyobro2647
      @doubleyobro2647 2 роки тому

      3 months late but its localScale, with a capital S

  • @neozoid7009
    @neozoid7009 2 роки тому

    This method also changes the sprite scale to 1,1,1 . But I want to have the scale to the same as I scaled it in the editor .

    • @Dani_Krossing
      @Dani_Krossing  2 роки тому +1

      If you don't want the scaling to change, then you create a separate sprite which is mirrored, that you then activate whenever going to opposite direction.

    • @neozoid7009
      @neozoid7009 2 роки тому

      @@Dani_Krossing awesome but how can I change the normal map , If I flipped the the sprite the normal map doesn't flip !

    • @guidesforuseveyone6834
      @guidesforuseveyone6834 2 роки тому +1

      @@neozoid7009 dude this 100% does not set the local scale to anything other than its opposite. How can multiplying by negative 1 change any number? if it is actually, do not change (localscake.x) but instead change entire local scale by new vector 3 and put in the values you have alreadu and just put a negative sign on the x.
      only thing Flip() does is take the x part of the local scale and multiply it by negative 1 which effectively flips it.
      DO NOT, mirror sprite like he is talking about if you wish to go with performance and have a bunch of moving parts. Though it wouldent be tjat bad i guess just weird if you have a bunch of colliders etc.

    • @neozoid7009
      @neozoid7009 2 роки тому

      @@guidesforuseveyone6834 thanks

    • @somedude8728
      @somedude8728 Рік тому +1

      I know im late here but the way I did this was
      if (Input.GetAxisRaw("Horizontal") > 0){
      gameObject.transform.localScale = new Vector3(Mathf.Abs(gameObject.transform.localScale.x),gameObject.transform.localScale.y,gameObject.transform.localScale.z);
      }
      if (Input.GetAxisRaw("Horizontal") < 0){
      gameObject.transform.localScale = new Vector3(-(Mathf.Abs(gameObject.transform.localScale.x)),gameObject.transform.localScale.y,gameObject.transform.localScale.z);
      }
      so it would just set the x to a positive number when going right and negative when going left without actually changing it, dunno if its a good way to do this though

  • @kelly_daniel_official
    @kelly_daniel_official 2 роки тому +1

    Don't you do PHP tutorials again

  • @kabhikachambala3392
    @kabhikachambala3392 2 роки тому +1

    It is too far from me.

  • @ghostisbusy2170
    @ghostisbusy2170 Рік тому

    dosent work with animations

  • @MoneyAlgorithim
    @MoneyAlgorithim 2 роки тому +1

    Sir can you do tutorial for
    When player hit the objects
    Pausing game and give him 2 choises for
    continue
    1 pay With Coins
    2 continue with ADS
    And if he dosent press any button for 3 seconds
    Game back to main menu scene
    Its like subway surfer game over system i need this please tutorial can you do it

    • @EpicBunty
      @EpicBunty 2 роки тому +1

      no thats so bad

    • @MoneyAlgorithim
      @MoneyAlgorithim 2 роки тому

      @@EpicBunty no thanks i done it 😁

    • @EpicBunty
      @EpicBunty 2 роки тому +1

      @@MoneyAlgorithim cool good luck getting nobody to play ur game lol

  • @jager356
    @jager356 2 роки тому

    why does unity dont have a fucking flip function so anoying

    • @Dani_Krossing
      @Dani_Krossing  2 роки тому

      It does. Inside the Inspector.

    • @jager356
      @jager356 2 роки тому

      @@Dani_Krossing found it
      Spriterenderer. Flip but I need to change all my images to sprite renderer I hate it

    • @Dani_Krossing
      @Dani_Krossing  2 роки тому

      @@jager356 You are just one big fluffy rainbow, aren't you 😂 How about that tedious "double clicking" every time you gotta open Unity Hub? Such a drag 🙄😂

    • @jager356
      @jager356 2 роки тому

      @@Dani_Krossing autostart

    • @jager356
      @jager356 2 роки тому

      Did it with scale how u did in ur video it works thx btw

  • @yeeyee_anime
    @yeeyee_anime Рік тому

    i hate boolenas

  • @zadeh79
    @zadeh79 2 роки тому +1

    gameobject.transform.localScale = new Vector3(-1f, 1f, 1f);

  • @cardario5323
    @cardario5323 2 роки тому +1

    Bruh why did n't you just do transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);

    • @Dani_Krossing
      @Dani_Krossing  2 роки тому

      There are many ways to do the same thing. If your code works for you then do that. 🙂

    • @cardario5323
      @cardario5323 2 роки тому +1

      @@Dani_Krossing ok man. DId n't expect you to answer your comments that frequently. You earned a sub bro

  • @quart7272
    @quart7272 2 роки тому

    Thanks

  • @sebastianmller4544
    @sebastianmller4544 8 місяців тому

    Thanks!