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

  Рет қаралды 33,351

Dani Krossing

Dani Krossing

Күн бұрын

Пікірлер: 119
@funkix60
@funkix60 2 жыл бұрын
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 :)
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
You are completely right. 🙂 Looking back I would have done it that way too. I’ll pin your comment for others to see. 😊
@jehriko7525
@jehriko7525 2 жыл бұрын
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!
@twist22
@twist22 2 жыл бұрын
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
@Hamlet2615
@Hamlet2615 2 жыл бұрын
This is so recent. You are the new generation brackeys my guy. love this!
@clark7831
@clark7831 Жыл бұрын
you are literally the goat thank you!
@premiumdrawback
@premiumdrawback Жыл бұрын
This helped so much! Thank you!
@serviceallies
@serviceallies Жыл бұрын
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
@JustinDunn_IT
@JustinDunn_IT 2 жыл бұрын
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.
@sreenjoymodak6636
@sreenjoymodak6636 3 жыл бұрын
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!
@xavierromeo7781
@xavierromeo7781 Жыл бұрын
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.
@jasminemerritt1831
@jasminemerritt1831 Жыл бұрын
Thank you for making this!
@ph0xnix373
@ph0xnix373 2 жыл бұрын
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.
@James_GamesYT
@James_GamesYT Жыл бұрын
WTH THIS IS SO COOL
@stealthyshiroean
@stealthyshiroean 3 жыл бұрын
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!
@Mr.Zita1
@Mr.Zita1 3 жыл бұрын
Thank you for the courses Mr Dani 🤓👍
@HullaBiloo
@HullaBiloo 2 жыл бұрын
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!
@NeosRS
@NeosRS 2 жыл бұрын
I have this same question actually, would love to know how to update it to do this.
@Jonny-op3wr
@Jonny-op3wr 2 жыл бұрын
Were you able to figure it out? If not he posted a simple solution in another persons comment. It was to make basically idle states for each direction they face and basically do check statements.
@troyna77
@troyna77 Жыл бұрын
you would need a variable to "remember" the last state before changing into the new. kindof like a temp/holding variable. then as you exit the loop or code block, perform an if (condition- ex. _tempState == _theStateYouWantToRevertBackTo) THEN {current variable = temp/holding variable}; else (continue without changing animation state); im sure there are a few other more sophisicated ways to handle this.
@onigiri_sakaro
@onigiri_sakaro Жыл бұрын
if anyone is searching for this, i achieved it by saving a "currentDirection" string when moving and adding 4 Idle States for each direction. i'll post the full code below. hope it helps! :) public class PlayerMovementAnimate : MonoBehaviour { public float moveSpeed; float inputHorizontal; float inputVertical; private Rigidbody2D rb; private Vector2 moveDirection; Animator animator; string currentState; string Player_Idle = "Player_Idle"; string Player_IdleUp = "Player_IdleUp"; string Player_IdleDown = "Player_IdleDown"; string Player_IdleLeft = "Player_IdleLeft"; string Player_IdleRight = "Player_IdleRight"; string Player_WalkUp = "Player_WalkUp"; string Player_WalkDown = "Player_WalkDown"; string Player_WalkLeft = "Player_WalkLeft"; string Player_WalkRight = "Player_WalkRight"; string currentDirection; void Start() { rb = gameObject.GetComponent(); animator = gameObject.GetComponent(); } public void Update() { ProcessInputs(); } public void FixedUpdate() { Move(); } public void ProcessInputs() { inputHorizontal = Input.GetAxisRaw("Horizontal"); inputVertical = Input.GetAxisRaw("Vertical"); moveDirection = new Vector2(inputHorizontal, inputVertical).normalized; } public void Move() { rb.velocity = new Vector2(moveDirection.x * moveSpeed, moveDirection.y * moveSpeed); if (inputHorizontal == 0 && inputVertical == 0) { if (currentDirection == "Right") ChangeAnimationState(Player_IdleRight); if (currentDirection == "Left") ChangeAnimationState(Player_IdleLeft); if (currentDirection == "Up") ChangeAnimationState(Player_IdleUp); if (currentDirection == "Down") ChangeAnimationState(Player_IdleDown); } else if (inputHorizontal > 0) { ChangeAnimationState(Player_WalkRight); currentDirection = "Right"; } else if (inputHorizontal < 0) { ChangeAnimationState(Player_WalkLeft); currentDirection = "Left"; } else if (inputVertical < 0) { ChangeAnimationState(Player_WalkDown); currentDirection = "Down"; } else if (inputVertical > 0) { ChangeAnimationState(Player_WalkUp); currentDirection = "Up"; } } void ChangeAnimationState(string newState) { if (currentState == newState) { return; } animator.Play(newState); currentState = newState; } }
@cooliogamerz3523
@cooliogamerz3523 Жыл бұрын
@@onigiri_sakaro Thank you so much, this is literally the first time ive replied to a youtube comment. Im pretty new and was struggling to figure out how to code dynamic idle animations using a state machine and this comment saved me. Great comprehensive code!
@erentst
@erentst 2 жыл бұрын
thanks for the tutorial!! have a great day sir
@rodrigochan3961
@rodrigochan3961 2 жыл бұрын
muchas gracias master sigue asi muy buenos tus tutos saludos desde mexico
@WarmFuzzlyBear
@WarmFuzzlyBear 2 жыл бұрын
Thank you! Subbed
@dashracer82
@dashracer82 Жыл бұрын
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?
@UnstableStrafe
@UnstableStrafe 2 жыл бұрын
For fixing the diagonal movements, I'm curious why you used a float instead of normalising the vector?
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Normalize is perfectly fine too, and a simpler solution if you just need equal speed in all directions. 🙂 The main difference is that the way I did it allow for more customization.
@WarmFuzzlyBear
@WarmFuzzlyBear 2 жыл бұрын
The Animator tree was supper hard this was easy to follow
@scottisitt
@scottisitt 2 жыл бұрын
That’s really cool that we can control the animation state with code instead of the blend tree! Thanks for showing us that! Question…if we do it through code, do we still need the animation states to be in Animator (as in 23:48)? EDIT: I'm guessing the answer is yes, since that's the player controller...
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
You are correct, we do still need them. 🙂
@scottisitt
@scottisitt 2 жыл бұрын
@@Dani_Krossing Thought so :) Thanks, again!
@atharvalangote8258
@atharvalangote8258 3 жыл бұрын
What if we want to keep the character looking in the direction after we stop pressing arrow keys?
@gralegath
@gralegath 2 жыл бұрын
Another set of sprites and then inside the state machine you'd need another set of states, somthing like PLAYER_IDLE_LEFT/RIGHT And probably another variable that stores your previous movement, just like newstate updates current state, only it dosent update with the new one.
@vilanstrikegaming5114
@vilanstrikegaming5114 3 жыл бұрын
Cool sprites
@Dani_Krossing
@Dani_Krossing 3 жыл бұрын
You are too kind hahaha 😂
@vilanstrikegaming5114
@vilanstrikegaming5114 3 жыл бұрын
@@Dani_Krossing yeah
@vipex5566
@vipex5566 2 жыл бұрын
thank you so much you are the bestt
@Pimple369
@Pimple369 2 жыл бұрын
What software are you using when you write your code? It just opens notepad for me.
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
When you install a Unity version, it prompts a window where you can choose to install Visual Studio as well. This is the editor that most use with Unity. 🙂 However I recommend downloading Visual Studio directly off of Microsoft's website, in order to get the latest version, since Unity prompts you to install the older 2019 version. I have a "how to install Unity" video on my channel, that shows how to set up Visual Studio correctly with Unity. I recommend watching that afterwards.
@Pimple369
@Pimple369 2 жыл бұрын
Ah, alright, thank you!
@charlieelane2047
@charlieelane2047 2 жыл бұрын
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
@kimbosan1
@kimbosan1 Жыл бұрын
Hello Elon Musk, thanks for great tutorial.
@wstkevin4161
@wstkevin4161 2 жыл бұрын
At 21:04 you mean diagonally again right? 😅
@SirAntonic
@SirAntonic 2 жыл бұрын
Quick question (I Hope) if i were to have the ending animation frame facing a different direction then default idle (aka an idle animation for left,right,up, and down) how would I go about having the code see that, The code currently if I'm walking and stop walking to the left the character snaps to facing forward instead of staying to the left.
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
You need to create idle animation sprites for all the directions, and just activate those depending on the direction you last moved
@gasmaskguy123
@gasmaskguy123 2 жыл бұрын
@@Dani_Krossingcould you please tell how do you do that? I know zero C# 🥲 (how to activate them on the direction last moved)
@corbinbujnowski4016
@corbinbujnowski4016 Жыл бұрын
I'm a newbie so take my advice with a grain of salt, but what I did was play the walking animation when Input.GetKeyDown then play the idle animation when Input.GetKeyUp. However, the animation is not fluid at all so I'm looking for a better way. What I would suggest doing if you create an animation state dependent on the virtual axis (like in the video), is to play the idle animation when the rigidbody's velocity is 0. I haven't tried this yet so I don't know if it works. I hope this helps a little bit if you still have this problem.
@sakshampathak4870
@sakshampathak4870 2 жыл бұрын
What version of unity are you using?
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
2020.3.25f1
@williamdahlstedt9532
@williamdahlstedt9532 Жыл бұрын
can someone help me, my character keeps drifting up and left, if I press right it moves right and up and if I press Down it moves left and down, I've tried multiple tutorials and the same problem
@zoxemo3838
@zoxemo3838 2 жыл бұрын
give me more man ;D
@Tae_Grixis
@Tae_Grixis 2 жыл бұрын
I've seen three different videos and they all did movement in three different ways. Does it change over time or are there really just many ways to do the same thing?
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
There are many ways to accomplish the same thing. Although in this video I would use the method I pinned a comment about, where a person suggested normalizing the vectors. 🙂
@Tae_Grixis
@Tae_Grixis 2 жыл бұрын
@@Dani_Krossing Thanks for the information.
@roythedroyd1694
@roythedroyd1694 2 жыл бұрын
so I'm using visual studios 2019 and rigid body 2d will not show up when I type it in. if anyone has a way to fix this it would be greatly appreciated.
@fishstack
@fishstack 2 жыл бұрын
What can i do if i get a CS0103 error? "Assets\Player\Scripts\PlayerController.cs(56,38): error CS0103: The name 'PLAYER_WALK_DOWN' does not exist in the current context"
@CoryPelizzari
@CoryPelizzari Жыл бұрын
Wait, why not just use 'normalized' for the horizontal and vertical vectors? I'm confused.
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Pinned comment 🙂
@bendugamr_the_blobfish
@bendugamr_the_blobfish Жыл бұрын
I copied everything exactly and for some reason it just doesn’t work. I click the buttons and it just sits there
@katiesanders3737
@katiesanders3737 9 ай бұрын
i've been trying different movement tutorials and although each one is different, my character always moves down nonstop when i run the program. is there a reason for this that i'm missing?
@Dani_Krossing
@Dani_Krossing 9 ай бұрын
If your character starts running as soon as you start the application, then it’s most likely the input logic that has a typo. If your code looks the same as mine, it should only run if you press a movement key. 🙂
@ItsAxoReal
@ItsAxoReal 2 жыл бұрын
using System.Collections; using System.Collections.Generic; using UnityEngine; public class JoystickPlayerExample : MonoBehaviour { public Joystick joystick; private Vector3 input; public float Speed = 5f; private void Update() { input = new Vector3(joystick.Horizontal, joystick.Vertical); Vector3 velocity = input.normalized * Speed; transform.position += velocity * Time.deltaTime; } }
@FrenchFried_ckd
@FrenchFried_ckd 2 жыл бұрын
you chad
@blvshh
@blvshh Жыл бұрын
The moment I started watching this I realized that you didn't explain how to import the player sprite and that's my main problem, Great tutorial but now I have to watch a whole separate video and it's a little bit annoying
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Neither the thumb or title on this video has anything to do with importing sprites though. 🙂 I do have a video that specifically goes into how to moody sprites in my Unity playlist.
@francoisdebruin6293
@francoisdebruin6293 2 жыл бұрын
Quick question i copied everything and everything works perfect only problem i have is it does not return to idle animation after buttons are stopped pressed any clues where to look? when i star the game the idle animation is just fine
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
I can with a 100% guarantee you that it is because of a typo. 🙂 Paste your code here and I'll take a look.
@francoisdebruin6293
@francoisdebruin6293 2 жыл бұрын
@@Dani_Krossing using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerController : MonoBehaviour { //Components Rigidbody2D rb; //Player float walkSpeed = 7f; // NOT IN USE float speedLimiter = 10f; float inputHorizontal; float inputVertical; //Animations and states Animator animator; string currentState; const string PLAYER_IDLE = "Player_Idle"; const string PLAYER_WALK_LEFT = "Player_Walk_Left"; const string PLAYER_WALK_RIGHT = "Player_Walk_Right"; const string PLAYER_WALK_UP = "Player_Walk_Up"; const string PLAYER_WALK_DOWN = "Player_Walk_Down"; // Start is called before the first frame update void Start() { rb = gameObject.GetComponent(); animator = gameObject.GetComponent(); } // Update is called once per frame void Update() { inputHorizontal = Input.GetAxisRaw("Horizontal"); inputVertical = Input.GetAxisRaw("Vertical"); if (inputHorizontal > 0) { ChangeAnimationState(PLAYER_WALK_RIGHT); } else if (inputHorizontal < 0) { ChangeAnimationState(PLAYER_WALK_LEFT); } else if (inputVertical > 0) { ChangeAnimationState(PLAYER_WALK_UP); } else if (inputVertical < 0) { ChangeAnimationState(PLAYER_WALK_DOWN); } } void FixedUpdate() { rb.velocity = new Vector2(inputHorizontal, inputVertical).normalized * walkSpeed; ChangeAnimationState(PLAYER_IDLE); } // Animation State Changer void ChangeAnimationState(string newState) { // Stop animation from interrupting itself if (currentState == newState) return; //Play new animation animator.Play(newState); //Update Current state currentState = newState; } }
@francoisdebruin6293
@francoisdebruin6293 2 жыл бұрын
thanx brother
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Your ChangeAnimationState(Player_Idle); needs to go inside a “else” statement, at the end of your “else if” chain inside Update() 🙂 I think that’s how I did it in the video too.. Right?
@francoisdebruin6293
@francoisdebruin6293 2 жыл бұрын
@@Dani_Krossing bro thanx allot
@cardikAssss
@cardikAssss Жыл бұрын
Character over accelerates on vertical and there-s a weird delay following this tutorial and the pinned comments
@valtris994
@valtris994 2 жыл бұрын
bro looks like elon musk
@leonschaub7414
@leonschaub7414 2 жыл бұрын
I copied the Code perfectly yet it still wont work. I can see the inputs getting registered but there is no applied velocity.
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
99% of the time when it's not working, it's because people made a typo or error while following the tutorial. Even if they said they "copied the code perfectly" 🙂 If you did everything like in the video, it should work.
@leonschaub7414
@leonschaub7414 2 жыл бұрын
@@Dani_Krossing ill just restart from scratch and follow everything cause i already did some things that might have messed it up. I only recently started working with unity and C#.
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
@@leonschaub7414 Learning how to trouble shoot is a skill that you will get good usage off, instead of starting over. 🙂 You will encounter errors and mistakes constantly while developing games. I'm guessing you didn't get any error messages since you don't know what is causing it... Did you make sure to add the script to the player? If you did add the script, then it is either the RigidBody not getting grabbed using 'GetComponent()' or it is a typo you made either in the 'if statement' where you check for movement, or when adding 'AddForce'.
@Mlkym1lk
@Mlkym1lk 2 жыл бұрын
I followed the code but my sprite is not moving...I tried to code it again but it still doesn't move. How do I fix it?
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Either you made a typo in your code (twice), you made a mistake in the Unity editor, or you are doing something different and not following the tutorial a 100% (for example implementing it into your own game). In 99% of the cases, that is what is causing the issue. Nothing in this tutorial is wrong or outdated. 🙂
@Mlkym1lk
@Mlkym1lk 2 жыл бұрын
@@Dani_Krossing I see. I will try it again and recheck if there're any errors. Thank you so much!
@Basulisk
@Basulisk 2 жыл бұрын
I’m confused and this is probably the wrong place to ask this but unity says I can’t start a statement with “else” (Idk how to code at all)
@Basulisk
@Basulisk 2 жыл бұрын
😓
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
I could explain to you why you get the error, but I don't think it would do you much good in the long run. 😕 Like you mentioned, you haven't learned any C# yet, which means you will struggle a lot with most code you write, because you jumped ahead in your learning a bit too fast. So here is what I recommend you do... Unity require than you know how to code at least a little bit, since coding goes hand in hand with game dev. 🙌 I know "programming" can sound scary if you are new, and I know that you are eager to get started on making a lot of fun games in Unity 🙂 ... but I can't stress enough HOW MUCH you would benefit from learning a bit of C#, before you start making your first game in Unity. I promise that you will be able to learn it fairly easy. 🙂 In this playlist I have here, you will learn how to do all the essentials when it comes to C# programming in Unity. It is explained specifically with COMPLETE beginners in mind, so it is a good place to start. It will also teach you why you are getting that error. 😉 kzbin.info/www/bejne/rqiZdYVtqtqBsJI&ab_channel=DaniKrossing
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
I should mention that the playlist is still on-going, and I am currently adding more videos to it. 🙂 If you want to skip ahead from that playlist I linked and try a more "complete playlist", then I have a "pure C# playlist" which isn't specifically related to Unity, but it WILL be something you use in Unity too. 🙂 kzbin.info/www/bejne/fnOUkoOPhbV9aJY&ab_channel=DaniKrossing
@Chasealex1145
@Chasealex1145 2 жыл бұрын
i keep geting the same error but unity does not tell me what it is
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
I can't help either unless I get the error hehe. Or at least a description of what is wrong.
@Chasealex1145
@Chasealex1145 2 жыл бұрын
@@Dani_Krossing It tells me the imput does not go were it is in the context of the code
@kupsoboy570
@kupsoboy570 2 жыл бұрын
it never works when i do it:('
@cardchronichlestcg925
@cardchronichlestcg925 2 жыл бұрын
kinda look like elon of the musk variety
@kaigoprod3238
@kaigoprod3238 2 жыл бұрын
MissingComponentException: There is no 'Animator' attached to the "Player" game object, but a script is trying to access it. You probably need to add a Animator to the game object "Player". Or your script needs to check if the component is attached before using it. ty for this usefull tutorial
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
You skipped a step in the video 🙂 Make sure you add the animator component in the Animation window.
@tuncyturan
@tuncyturan 2 жыл бұрын
Add Animator component to Player object and drag your animation controller to object of animation controller propertiy
@geometrydash2118
@geometrydash2118 2 жыл бұрын
why am i geting no movement ???????????????
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Most likely a typo or mistake 🙂
@IberianInteractive
@IberianInteractive Жыл бұрын
nah bruh... i get this mistake... Gravedad Código Descripción Proyecto Archivo Línea Estado suprimido Error CS0104 'Input' es una referencia ambigua entre 'UnityEngine.Input' y 'UnityEngine.Windows.Input' Assembly-CSharp
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Brah dude... Gotta send it in English if I am to help. 😉
@homerocapuano790
@homerocapuano790 2 жыл бұрын
Mine face 22 errors
@cartermcknight4054
@cartermcknight4054 2 жыл бұрын
I keep getting complier issues
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
What compiler error message are you getting? It should tell you in the Unity console. Always share that. 🙂
@cartermcknight4054
@cartermcknight4054 2 жыл бұрын
@@Dani_Krossing thats the funny bit theres nothing in the console
@scottisitt
@scottisitt 2 жыл бұрын
Isn't Input.GetAxisRaw() using the old input system? Is there a way to modify this code using the new input system? I mean, I'll look online, but just wanted to ask. Edit: Would something like this work… void Update() { Walk(); } void OnMove(InputValue value) { moveInput = value.Get(); } void Walk() { float velocityX = moveInput.x * walkSpeed; float velocityY = moveInput.y * walkSpeed; rb2d.velocity = new Vector2(velocityX, velocityY); } …or something like it? Would the Walk() be called in a FixedUpdate() instead?
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
The new input system is a package you need to install, which comes with some cool benefits. 🙂 There is nothing wrong with programming the movement like this if you don’t plan on making the movement complex, or cross platform compatible. It is also a complete tutorial in itself to set up, which is why you will see KZbinrs do tutorials without it. Otherwise it would confuse more than what it benefits hehe.
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Walk() would need to go into a FixedUpdate() since you are using a rb2d component for movement. I wouldn’t include the rb2d.Velocity inside your update, since it would run even if there is no input or the input hasn’t changed. Which is just going to collect garbage. So I would do an extra check to see if the input has changed since last frame. Other than that, if you plan on using the new input system then you are headed in the right direction. 🙂
@scottisitt
@scottisitt 2 жыл бұрын
@@Dani_Krossing I see. Thanks!
@PolySh4pe
@PolySh4pe Жыл бұрын
Awful tutorial. For example, at 6:14, you wrote if an brackets and it just made those little thingy's pop up. How???
@Dani_Krossing
@Dani_Krossing Жыл бұрын
This tutorial teaches how to create basic character movement. It’s not meant to teach the VERY basics of how to use Visual Studio. 🙂 If you struggle with basic VS shortcuts, then I recommend starting from the beginning, instead of jumping ahead.
@PolySh4pe
@PolySh4pe Жыл бұрын
Nah man this comment was satire lel, i love how despite me being i prick you didnt get angry but instead handled it. new sub. :) @@Dani_Krossing
@cartermcknight4054
@cartermcknight4054 2 жыл бұрын
It keeps say "All complier errors have to be fixed before entering playmode" how do i fix this
@WarmFuzzlyBear
@WarmFuzzlyBear 2 жыл бұрын
Fix the error it should tell you what error you have on your code
@Chasealex1145
@Chasealex1145 2 жыл бұрын
it keepgiving me errors and i have been trying this for four hours straight
@Dani_Krossing
@Dani_Krossing 2 жыл бұрын
Like I replied in the first comment you made, I need to see the error to help you. 🙂
@CLAPNUGGETSdani
@CLAPNUGGETSdani Жыл бұрын
what did i do wrong using System.Collections; using System.Collections.Generic; using UnityEngine; public class playercontroller : MonoBehaviour { //components rigidbody2D rb; //player float walkspeed = 4f; float speedlimiter = 0.7f; float inputhorizontal; float inputvertical; // Start is called before the first frame update void Start() { rb = gameobject.getcomponent(); } // Update is called once per frame void Update() { inputhorizontal = input.getaxisraw("horizontal"); inputvertical = input.getaxisraw("vertical"); } } void fixedupdate() { if (inputhorizontal ! = 0 || inputvetical ! = 0) { rb.valocity = new vector2(inputhorizontal * walkspeed, inputvertical * walkspeed); } } }
@Dani_Krossing
@Dani_Krossing Жыл бұрын
Every line you wrote has at least one error in it. 😅 You didn't capitalize properly, you misspelled words, and you included empty spaces in places there shouldn't be any. Careful not being careless when following the tutorials, otherwise you will have a very painful time in the future doing constant bug fixing. 🙂 In this case here, I don't think it would be productive if I just told you where the errors are. I think you would get more out of trying to fix your code by going over it once more on your own... And if you then still can't figure out where the errors are, then you are more than welcome to ask for help again. 🙂
@CLAPNUGGETSdani
@CLAPNUGGETSdani Жыл бұрын
@@Dani_Krossing i need to take a step back
@Chasealex1145
@Chasealex1145 2 жыл бұрын
i hate unity
Making a TOP-DOWN SHOOTER in 10 minutes VS 1 hour VS 1 day!
8:34
Blackthornprod
Рет қаралды 148 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
Гениальное изобретение из обычного стаканчика!
00:31
Лютая физика | Олимпиадная физика
Рет қаралды 4,8 МЛН
Cat mode and a glass of water #family #humor #fun
00:22
Kotiki_Z
Рет қаралды 42 МЛН
The Unity Tutorial For Complete Beginners
46:39
Game Maker's Toolkit
Рет қаралды 4,1 МЛН
I tried coding my own graphics engine
4:23
Garbaj
Рет қаралды 219 М.
10 Unity Tips You (Probably) Didn't Know About
6:47
Sasquatch B Studios
Рет қаралды 49 М.
2D Top Down Movement UNITY Tutorial
7:21
BMo
Рет қаралды 231 М.
I Helped 2,000 People Walk Again
15:31
MrBeast
Рет қаралды 23 МЛН
How to make a good platforming character (Developing 6)
14:50
Game Maker's Toolkit
Рет қаралды 428 М.
skibidi toilet - season 25 (all episodes)
51:06
DaFuq!?Boom!
Рет қаралды 8 МЛН
50 Digital Art Tips in 5 Minutes
5:33
Skynix Art
Рет қаралды 1,7 МЛН
Why you should switch to Unity's New Input System (and how easy it is)
9:51
Jason Weimann (GameDev)
Рет қаралды 34 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН