How to Make SMOOTH Top Down Character Movement in Godot!

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

КОМЕНТАРІ • 55

  • @martinithechobit
    @martinithechobit 10 місяців тому +25

    Small tubers like this are the real gems and mvp.

    • @kobedev
      @kobedev  10 місяців тому +2

      Tyyyyyyyy

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

      Yes absolutely

  • @cosmocode75
    @cosmocode75 2 місяці тому +4

    "sbrueceibe!" 🤣you got me rollin', gonna sub for sure!

  • @Mr_Beagle
    @Mr_Beagle 18 днів тому

    Excellent tut, well done! 👏 Newb question... if I wanted to trigger one of 8 movement animations (up / up-left / left / down-left / down / down-right / right / up-right), would I just use a series of conditionals on the x / y vector values to fire the appropriate walking animation?

  • @K.E.S.D
    @K.E.S.D 10 днів тому

    Great tutoriel thanks

  • @galacticgon925
    @galacticgon925 11 місяців тому +8

    I think in Godot 4. Doesn't it make more sense to just use get_vector?
    var direction = Input.get_vector("left","right","up","down")

    • @kobedev
      @kobedev  11 місяців тому +3

      Oh damn I didn’t even realise they had that method In godot 4 I definitely need to read the docs 😂

    • @Affected333
      @Affected333 11 місяців тому

      in my run state in my state machine, how can i use this movement method for a Input.is_action_pressed(etc all the directions and have it 8 way movement

  • @lay2BH
    @lay2BH 9 місяців тому +3

    Is there a way I can make the movement less slidey? I would like more precise movement when the key is released. Amazing tutorial, really helped me out.

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

      Increasing the acceleration should do the trick

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

      probably change your acceleration to 1

  • @ariB65
    @ariB65 20 днів тому +1

    Why would we use a sprite node over an animated sprite node? I’m very new to Godot and curious how choosing or the other might impact making the player.

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

      I got the same question maybe because animated sprite is more customizable?

    • @avanti488
      @avanti488 19 днів тому

      @@Whhatt I think choosing an animated sprite would mean you can add frames and animation to the character

    • @ariB65
      @ariB65 17 днів тому

      I understand that adding in an animated sprite would allow for adding animation, my question is why would that not be used here? In other tutorials I have seen the same Sprite2D node used over the AnimatedSprite2D, I am curious if that is because it has other wider implications for coding or programming other than being able to add animation frames.

    • @Whhatt
      @Whhatt 17 днів тому +2

      @ariB65 using animated sprite 2d is better most of the time if you plan on animating later

  • @JayAether
    @JayAether 5 місяців тому +4

    (new to godot)
    im pretty sure if you want to remove the accel / sliding affect you can do it like
    velocity = playerInput * speed * delta
    but you have to put SPEED to a mil or smthn high, i think

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

    how should i change the code if i would like my character to start walking instantly but keep the sliding effect when theres no input atm?

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

    How do i add like animation to it like left, right, up, down animation

  • @mariomanchevsky
    @mariomanchevsky 2 місяці тому

    Hey Kobe. I followed your guide and created the same player movement you're showing here. WASD works great. But when I incorporate MarcoFazio's Virtual Joystick add-on from the AssetLibrary (following WisconsiKnight's tutorial, a fellow Godot UA-camr), the movement feels a little wonky, especially when attempting to drive in any direction that's not the 0, 45, 90, 135, 180, 225, 270, 315 or 360 degree of the joystick, if that makes sense. Could you help us incorporate the joystick into Godot? Or perhaps make our own? :')

    • @kobedev
      @kobedev  Місяць тому +1

      I’m not too sure how the plugin works but I would try to get whatever the vector is of the joystick direction is and then I would apply a force is in that direction (you can do this by normalising the vector)

  • @ptaha3109
    @ptaha3109 2 місяці тому

    Thank you so much for the tutorial, but I have one question. What if I want the camera of the player to collide with the edges of the scene? I mean, if player reaches the corner of the map, how do I make the camera stop and not go through the borders?

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

      I think there is a setting in the camera called something like damping or maybe clipping

  • @connerolson9618
    @connerolson9618 2 місяці тому

    How did you move the character to the tile map scene?

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

    At around 2:31 I am getting the error message ''Cannot find property ''get_action_strength'' on base ''vector2'' and I dont understand what that even means.

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

      You need brackets because get_action_strength() is a method not a property. The error is basically saying you are trying to access a property of a vector2 (a property is like a variable at the top such as ‘x’ or ‘y’) but a method is something you need to call so we need the brackets to make sure we’re calling a method and not accessing a property

  • @louismarques6803
    @louismarques6803 4 місяці тому

    How would you handle tile-moving characters? If i press my walk key once i want it to move one tile, for example.

    • @kobedev
      @kobedev  4 місяці тому

      I would probably set a vector or a scalar value you want the character to move with and instead of using Input.get_action_direction, get_action_strength or is_action_pressed, use Input.is_action_just_pressed for your up, down, left and right movements, and move that specified length for each input, this way it will only be called each time you press the key, not being called for as long as the key is held down

  • @HeavenlyRestricted-777
    @HeavenlyRestricted-777 3 місяці тому

    cannot find property "get_action_strenght" on base vector 2. what must i do ?

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

      Capitalise input

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

      You spelt strength wrong in your comment, maybe that’s why

  • @tofuryu3567
    @tofuryu3567 9 місяців тому +2

    but how can i add movement animation to this

    • @kobedev
      @kobedev  9 місяців тому +4

      const MIN_SPEED = 20
      If velocity.length() > MIN_SPEED:
      $AnimationPlayer.play(“run”)
      else:
      $AnimationPlayer.play(“idle”)

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

      @@kobedevhow would you put a run up or run down animation

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

      ​@@DyIanGaming If velocity.y > MIN_SPEED:
      $AnimationPlayer.play(“run_down”)
      elif velocity.y < -MIN_SPEED:
      $AnimationPlayer.play(“run_up”)
      elif velocity.x > MIN_SPEED:
      $AnimationPlayer.play(“run_right”)
      elif velocity.x < -MIN_SPEED:
      $AnimationPlayer.play(“run_left”)
      else:
      $AnimationPlayer.play(“idle”)

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

      @@kobedev thank you so much I looked through 5 different tutorials to try to get this working

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

      @@DyIanGaming no worries bro i totally get that feeling when you finally fix that one thing that's bugging you so I'm glad to have helped!

  • @baloch98764
    @baloch98764 5 днів тому

    the code isn't efficient you could use Input.get_vector instead and move_and_slide underneath it use a velocity var which is gonna be velocity = direction * speed and the Input.get_vector is gonna be the in the direction variable

  • @savagemonster6373
    @savagemonster6373 2 місяці тому

    How do you disable the gravity?

    • @kobedev
      @kobedev  2 місяці тому

      It’s in the editor settings, select floating under motion mode

    • @kobedev
      @kobedev  2 місяці тому

      You might be using the wrong node type

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

    where can i find this but in C# , I have godot but im used to coding in c#

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

      I’m actually not familiar with any c# channels sorry, I also don’t know c#

    • @asdfghjkl-jk6mu
      @asdfghjkl-jk6mu 6 місяців тому

      no you're not "used to coding in c#". you're used to "copying code" in c#. because it's really simple to implement this

  • @lowestpoint1047
    @lowestpoint1047 8 місяців тому +3

    Sbriceibed to the channel

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

      Let’s go bro! Glad you enjoyed

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

    Ha, now you can make money

  • @Devlalee
    @Devlalee 11 місяців тому +6

    Shouldn't have posted this during NNN🔥

    • @kobedev
      @kobedev  11 місяців тому +8

      My apologies for any unintentional disturbance to the NNN sanctity. I understand this month requires a next-level commitment, and I respect your dedication to the cause. Let's turn this into a positive challenge-you've got this! Surround yourself with distractions, find new hobbies, or maybe binge-watch some non-triggering content. Remember, it's not just a challenge; it's a testament to your willpower. Stay strong and conquer NNN! 💪🚀

    • @jessicahatesbigyoutubers
      @jessicahatesbigyoutubers 11 місяців тому +1

      Great response.