TOP DOWN MOVEMENT 2D IN UNITY 🎮 | How to Make Top Down Movement in Unity | Learn Unity For Free

preview_player
Показать описание
Hi everyone! 🙂 Today I will show how to make top down movement in Unity, or how to make top down movement in Unity for beginners. We will also learn how to animate movement through a script, instead of using the Animator, which is much easier.

➤ TIMESTAMPS

00:00:00 - What I have so far
00:02:25 - Player movement (PlayerController)
00:10:44 - Player animations (using code)

➤ GET ACCESS TO MY LESSON MATERIAL HERE!

First of all, thank you for all the support you have given me!

I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!

I am now using Patreon and YouTube Memberships to share improved and updated lesson material, and for a small fee you can access all the material either from my memberships or Patreon, depending on your preference. I have worked hard, and done my best to help you understand what I teach.

I hope you will find it helpful :)

Рекомендации по теме
Комментарии
Автор

Hi ! This is a great vid thanks !

No offense, but your code looks very complicated and can be refactored a lot using Vector2().normalized method.

Void FixedUpdated() {
rb.velocity = new Vector2(inputHorizontal, inputVertical).normalized * walkSpeed ;
}
With this, no need to set up a speed limiter since is Always returns a vector with magnitude of 1. Meaning Diagonal movement get 1 * walkspeed.
Plus, no need to check IF key is pressed since Input.GetAxisRaw will be 0 to 1 so if no key is pressed nothing in happening anyway right?

Good day to you good sir :)

funkix
Автор

I just want to say I've been struggling with this for a while and this video has helped me immensely, thanks for making it!

jehriko
Автор

Thanks so much for this! I've been agonizing over using the animator visual representation with transitions and all that jazz and my head's been spinning over a bug I couldn't figure out. I reworked in code and the whole thing feels way simpler now. Thank you! :D

twist
Автор

Hi I was just wondering if there was any way to change it so instead of reverting the player back to the front idle animation you could make it so that the idle animation changes depending on the last input made by the player? Like an Idle_Left animation playing after moving left instead of the player going back to the default and looking down afterwards. Great tutorial by the way!

HullaBiloo
Автор

I really like the way you explain what each line is actually doing. Makes things make a lot more sense. Have you done anything with the new unity input methods? Feel like they streamline the movement process a lot in some other tutorials I found. Just think you do a much better job of explaining what is actually happening and what various codes do.

phxnix
Автор

This is so recent. You are the new generation brackeys my guy. love this!

Hamlet
Автор

hey! I love your tutorials they are the best tutorials one could ask for! I've already completed the HTML/CSS and the javascript courses. Keep it up!

sreenjoymodak
Автор

Huh, that is different. I originally was going to skip over this video because I already had a working top-down movement controller for my player. However, I wanted to see how you did it and thought it would be good for the learning process. Didn't expect a state machine! I think a lot of tutorials do talk about using the animator and creating blend trees then manipulating those through the code which is pretty much what I did.

Also, you did bring up a very important point that I forgot about. My character moves too quickly when walking diagonally lol. I'll need to fix that. Thanks for the great tutorial and the different approach!

stealthyshiroean
Автор

Hi !
Thank you really much, you helped me a lot.
I reworked your code a little bit to use different idle animations depending on the last direction.
I have a direction integer to store the last direction
And I use switches and cases instead of a bunch of if-statements.

xavierromeo
Автор

Bro, you are completely underrated. The laymen explanations as you go through for why you do something 100% is how I learn. Sure, maybe code can be refactored like @Don't Blink said, buuut for someone like me (with slight coding history) just trying to get off the ground (and understands the first way you do something is not always the optimal) its a godsend for them.

So thanks.

JustinDunn_IT
Автор

For any fellow nerds who like to make sure the math is precise: to make sure the diagonal movement speed perfectly matches the regular speed, the correct equation is diagonal movement speed times 0.707106. So even .7 is pretty darn close

serviceallies
Автор

Could you show me how, with this code, I could use the flipped variation of the WalkRight animation as a WalkLeft? My tileset only has right animations for walking and attacking, and death. or would it be easier to just add left animations to my tileset?

LittrellRacing
Автор

thanks for the tutorial!! have a great day sir

erentst
Автор

At 21:04 you mean diagonally again right? 😅

wstkevin
Автор

For fixing the diagonal movements, I'm curious why you used a float instead of normalising the vector?

UnstableStrafe
Автор

What software are you using when you write your code? It just opens notepad for me.

Leggl
Автор

What if we want to keep the character looking in the direction after we stop pressing arrow keys?

atharvalangote
Автор

muchas gracias master sigue asi muy buenos tus tutos saludos desde mexico

rodrigochan
Автор

The Animator tree was supper hard this was easy to follow

PinoyGamer
Автор

How would I set up collisions from here so that my player stops walking through trees. I've got it set up on my tile map and have the box collider 2D on my player but no idea how to code it

charlieelane
welcome to shbcf.ru