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>
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.
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.
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?
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!
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
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.
@@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
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
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?
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
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.
@@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!
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》?
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 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.
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
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
@@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 🙄😂
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>
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.
you're a fricken lifesaver!!! thanks so much for these tutorials! I've actually learned so much just through you stuff!
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. 👏❤
Thank you so much ! Could not get the child objects to flip with the character until using this !
Thanks, your method also worked for other scales instead of having to be fixed at 1
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.
Its crazy how one small error can cause something to not work lol, anyway this helped me find my issue. Thanks!
Learning to create custom animations for my games, thanks!
Thanks, helped me a lot
Thank you this is super straightforward!
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
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.
Thanks a lot for the tutorial!
Could you pls do a Tutorial for rotating the player in the direction he moves. (top down 2D)
I uploaded one a few days ago ^^
my player keeps getting fat whenever I move😭 what did I do wrong?
nevermind I fixed it 👍 great vid!
thanks a lot
Interesting Video!
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?
Thank you, very well and good explained
Thanks! This got me untuck in minutes.
Hi, I'm a newbie and curious why didn't you use the component Sprite Renderer by Flip-Y ?
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!
Thanks that was what I looked for.
Thanks you very much! nice tutorial!
he making flip when i jump and go left or right but when i go right or left its not flip
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
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.
@@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
Thanks
Thanks for the video great help. Also on an unrelated note are you related to Elon Musk? the similarities are uncanny
Thank you so much man!
For Godot users: This can also be applied in Godot.
thank you so much, subbed
Thanks you!
The Elon Musk of game design. Nailed it, thanks.
Don't insult them like that
elon musk is a dumbass why would you even compare the two lmao 😭
Thank you, saved so much time🙏
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
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?
I like your hair 😆😆
Hi Dani my character slides quick of he side either direction and carries on moving ? what could be the issue?
How can we make it follow the mouse? Like flip when mouse is on the left or right.
can someone help me? i copied your movement script and my guy slides around like hes on ice? how do i prevent this?
Hey, stupid question. Why do we need to delcare gameobject.trasnform.localSclae = currentScale again?
thanks this wasn't in the 2d character movement video
but how about up and down?
how do you add jump?
I cant flip my character XoX .help ,please....
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
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.
@@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!
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》?
3 months late but its localScale, with a capital S
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 .
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.
@@Dani_Krossing awesome but how can I change the normal map , If I flipped the the sprite the normal map doesn't flip !
@@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.
@@guidesforuseveyone6834 thanks
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
Don't you do PHP tutorials again
It is too far from me.
dosent work with animations
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
no thats so bad
@@EpicBunty no thanks i done it 😁
@@MoneyAlgorithim cool good luck getting nobody to play ur game lol
why does unity dont have a fucking flip function so anoying
It does. Inside the Inspector.
@@Dani_Krossing found it
Spriterenderer. Flip but I need to change all my images to sprite renderer I hate it
@@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 🙄😂
@@Dani_Krossing autostart
Did it with scale how u did in ur video it works thx btw
i hate boolenas
gameobject.transform.localScale = new Vector3(-1f, 1f, 1f);
hero
Bruh why did n't you just do transform.localScale = new Vector3(transform.localScale.x * -1, transform.localScale.y, transform.localScale.z);
There are many ways to do the same thing. If your code works for you then do that. 🙂
@@Dani_Krossing ok man. DId n't expect you to answer your comments that frequently. You earned a sub bro
Thanks
Thanks!