How to Create SMOOTH Platformer Player Movement in Godot 4

Поділитися
Вставка
  • Опубліковано 19 тра 2023
  • In this video I go over step by step how to create smooth platformer player movement in Godot 4. Having good player movement in any game is almost always a number 1 priority, it is very important to the success of a game. So this video goes over everything you need to know to create smooth player movement in Godot 4.
    ----------------------------------------------------------------------------------------------------------------------------------------
    Thank you so much for watching I really hope this video helped.
    if you did enjoy then please go and click that subscribe button to help out the channel. I means so much and I love your feedback in the comments to let me know what it is that you enjoyed. Again thanks so much and I would love to see you again!
    have a great rest of you day and of course be safe :)
    - thanks DevWorm,
    ----------------------------------------------------------------------------------------------------------------------------------------

КОМЕНТАРІ • 130

  • @mateo3748
    @mateo3748 5 місяців тому +32

    This tutorial is good, however it doesn't mention the most important thing about movement, delta. Whenever you do something related with movement you MUST use delta in your equations to be independent of framerate. Your program will work on your computer, but it wont in computer with slower or faster framerates at least for the falling part you didn't use delta. move_towards at least in godot 4 has a parameter time that takes to go to peak speed and it has delta incorporated so we wont have to worry about it on there. If someone uses delta for gravity and its too slow means gravity is too small and you need to make it bigger, remember its measured in how much a pixel is measured.

    • @dev-worm
      @dev-worm  5 місяців тому +12

      very good point! thanks.. sorry this tutorial was a while ago!! I'm going to pin this comment! thank you!

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

      Ok. I understand that, but where should I put the delta in the full code?

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

      What you say about using "delta" is correct, in general. However, as long as you use "move_and_slide()" to move your character, "delta" is used automatically in Godot 4

    • @1tzRusty
      @1tzRusty 26 днів тому +1

      you dont have to use that if you are gonna use move_and_slide function

  • @m4rt_
    @m4rt_ 8 місяців тому +31

    You don't need to normalize a vector that is only on the x axis. You should normalize it when you have it be on the x and y axis, and this is so that you don't go faster diagonally.
    The math for normalizing a vector 2 is: vector / vector.length()
    which would for (1, 0) be (1, 0) / sqrt(1^2 + 0^2) or (1, 0) / 1 or (1 / 1, 0 / 1) or (1, 0)
    and for (-1, 0) it's (-1, 0) / sqrt(-1^2 + 0^2) or (-1, 0) / 1 or (-1 / 1, 0 / 1) or (-1, 0)
    for a vector like this (1, 1) it would be (1, 1) / sqrt(1^2 + 1^2) or (1, 1) / 1.4142 or (1 / 1.4142, 1 / 1.4142) or (0.7071, 0.7071)

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

      it's just pythagoras to align it to a unit circle then?

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

    Thank you for this tutorial sir. I'd gotten a pdf but it was in godot 3 and i couldn't find one for 4. So I'm pushing and finding relevant tutorials on UA-cam. This helped a lot, will be looking forward to seeing more 🙏🙏🔥

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

    Very nice content! Thank you so much!

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

    Great stuff as always

  • @Dailyz.
    @Dailyz. Рік тому +1

    thank you very much this was very helpful

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

    VERY MUCH THANK YOU

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

    Keep up the excellent work.

  • @Potat_44
    @Potat_44 10 місяців тому +1

    just wondering, the jump timing that's used is really jolty, how would I be able to slowly decrease upwards acceleration so that its snappy take-off but it gives some time to react before reaching the peak of the jump? more Mario-esc if more clarification is needed.

  • @ikr4m69_5
    @ikr4m69_5 7 місяців тому

    this is amazing

  • @LeQuietkid
    @LeQuietkid 6 місяців тому +2

    For those who don't care about acceleration and just want movement, you can do replace:
    var direction = Input.get_axis("ui_left", "ui_right")
    if direction:
    velocity.x = direction * SPEED
    else:
    velocity.x = move_toward(velocity.x, 0, SPEED)
    with:
    if Input.is_key_pressed(KEY_A):
    move_local_x(-5)
    if Input.is_key_pressed(KEY_D):
    move_local_x(5)
    If you want movement for up and down, do the same thing but use KEY_W and KEY_S and use move_local_y instead of move_local_x
    (Make sure to keep the move_and_slide() if you want gravity)

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

      If you do this, though, It's gonna be harder to implement things like wall-jumps and knockback, since holding down a directional key will override your velocity immediately.

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

      @@zakatalmosen5984 wall jumps, not so much.. Idk about knock back though, as I don't use it in my games

  • @lurkera7351
    @lurkera7351 Рік тому +5

    Hello can you create a tutorial for pathfinding on Godot 4? I watched your video in Pathfinding in Godot 3.5, and I really like that enemy pathfinding on my Godot 4 since they apparently remove or changed the Navigation2D node so I'm stuck now.

    • @dev-worm
      @dev-worm  Рік тому +3

      im owrking on one right now, its complex and im having a hard time understanding how to do it in godot 4 my self lol

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

    How would someone set up a jump animation with this code? I noticed if its put under the jump input the anim is cut off by either "run" or "idle"

  • @peterfields2179
    @peterfields2179 7 місяців тому

    Why have the friction higher than acceleration? Leads to a weird game feel (stopping quicker than you change direction)

  • @mintshake8138
    @mintshake8138 23 дні тому

    is there a way to get it so the character isn't immediately flung into the air when i jump?

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

    Hey! great vid but I had one problem, the jump was for some reason sending me into the floor instead of the air, and an easy fix that I found was just setting the jump power to -2000.

    • @dev-worm
      @dev-worm  6 місяців тому

      yes. negative numbers mean up on a Vector2 and positive numbers mean down on a Vector 2.

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

    i think input_dir = input_dir.normalized() isnt needed bcs previous line will give value between 1 and -1 anyway

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

    You are a good I LOVE YOU

    • @dev-worm
      @dev-worm  Рік тому +1

      haha tysm, glad it helped

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

    Having a problem where my jumps are much shorter than they should be and gravity only comes into effect while moving with left and right. Been trying to fix it for a while now but can't figure it out

    • @Link-zn9ye
      @Link-zn9ye 3 місяці тому

      Instead of calling the functions in "func _physics_process(delta):" like this:
      player_movement()
      jump()
      Try this:
      jump()
      player_movement()
      It worked for me, but i dont know how to normalize the jump with the horizontal movement (while the the horizontal movement binded keys and jump binded key are pressed at the same time, the character moves faster that it should be).

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

    how to add the animations then? (im new so idk very much)

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

    yesssirrrrr

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

    I dont think this computer works on some computers, I followed the text twice to make sure but my jumps last one fifth the time his do and my movement is broken. Sadly I cannot find any new tutorials on how to implement acceleration and friction :(

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

    The jumping feels very stiff, is there a way to make this more smooth/floaty?

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

      No do you know how to change collision shape?

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

      Look into the GDC talk "Math for Game Programmers: Building a Better Jump"
      or if you want less of the math look at the video "Making a Jump You Can Actually Use In Godot"

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

    please, make tutorial with method play_animation() (L)

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

    Are you still going to make another video on the dialogue manager plug-in?

    • @dev-worm
      @dev-worm  Рік тому

      most likely not... do you need help with custom bubbles? if so let me know and i can link you to a really well made video over it

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

      @@dev-worm The bug I told you last time that you can move and click on it multiple times. I'd really like a video fix on that whenever possible

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

    how do you find the player node?

  • @Bomilk
    @Bomilk 10 місяців тому +1

    hey! i followed the tutorial correctly, but the player only moves when I stop touching the key assigned to move to x side, like it was charging the movement or something like that. I tried to modify the variables on the code, but i cant find wheres is the error.
    note: the character has an animation to walk. i put the animation in the character and it works, so the code detects correctly when the axis X changes to 1 or -1
    if you can reply, that would be really helpful :)

    • @GravityCreep
      @GravityCreep 8 місяців тому +1

      same

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

      dude,i spend 3hour findout
      in physics func
      if Input_dir != Vector2.ZERO and is_on_floor():
      and it work

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

      could you fixed? I have the same problem

    • @Bomilk
      @Bomilk 8 місяців тому +1

      ​@@cmescandonpardo
      yeah, i fix it like the day before. honestly i have no idea what i modified bc that was 1 month ago LOL so i will drop the code here and check if your character can move properly with it
      extends CharacterBody2D
      const speed = 60
      const jump_power = -400
      const acc = 30
      const friction = 30
      const gravity = 40
      const max_jumps = 2
      var current_jumps = 1
      func _physics_process(delta):
      var input_dir: Vector2 = input()
      # if input_dir == Vector2(-1.0, 0.0):
      # flip_h = true
      # else:
      # flip_h = false
      #
      if input_dir != Vector2.ZERO:
      accelerate(input_dir)
      player_animation("walk")
      else:
      add_friction()
      player_animation("idle")
      player_movement()
      jump()
      func input() -> Vector2:
      var input_dir = Vector2.ZERO
      input_dir.x = Input.get_axis("ui_left", "ui_right")
      input_dir = input_dir.normalized()
      return input_dir
      func accelerate(direction):
      velocity = velocity.move_toward(speed * direction, acc)
      func add_friction():
      velocity = velocity.move_toward(Vector2.ZERO, friction)
      func player_movement():
      if Input.is_action_just_pressed("ui_right"):
      $Sprite2D.flip_h = true
      move_and_slide()
      if Input.is_action_just_pressed("ui_left"):
      $Sprite2D.flip_h = false
      move_and_slide()
      func player_animation(status):
      $AnimationPlayer.play(status)
      func jump():
      if Input.is_action_just_pressed("ui_up"):
      if current_jumps < max_jumps:
      velocity.y = jump_power
      current_jumps += 1
      else:
      velocity.y += gravity
      if is_on_floor():
      current_jumps = 1

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

    Great tutorial! I am new to coding and learned, that it is always good to incorporate the "delta" into the code. For example with the gravity (velocity.y += GRAVITY * delta). Unfortunately I was not able to implement it on my own. Is it necessary here to add the delta to the movement?

    • @dev-worm
      @dev-worm  Рік тому

      what do you mean you were not able to implement delta?

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

      ​@@dev-wormwhen adding delta to any part of the jump function, I received the error, that delta was not declared in the current scope, or something. I was trying to make it work, but failed. Is it even necessary to use it in the calculations here? I am using godot only for a couple of days and learned in a tutorial to always add the delta to make for differences in the frame rate.
      I was trying to change the code a little bit to make the jump height variable depending whether the player pressed jump longer or shorter and wanted to make the trajectory of the jump more realistic. In your version the jump feels weird, because the speed of the movement does not change. I think it should start slower, then reach top speed and slow down towards the eclipse of the jump. Also the speed of the down movement should be different than the up movement. Also I wanted to implement, that the char keeps the momentum of a movement. Meaning, when running and jumping, he keeps his momentum to the side, even after releasing or pressing the opposite move button.
      I asked chatgpt to help and it always suggested function, that included delta, which did not work.

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

      @@finsends8415 you have to type those in a physics process function

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

    if im holding left or right when i jump i kind of glide in the direction im holding, but i stop gliding when i release. any fix for this?

    • @dev-worm
      @dev-worm  Рік тому

      you would have to check if the player is on the floor before you stop the players movement

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

      alright thanks

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

      @@dev-worm same problem but dont really understand what you mean.....

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

    I had a question about the gravity. I'm currently using the most recent version (4.2.1) of Godot and that may be the reason for my problem, but I am not sure. I copied line for line and notice we have different results. instead of gravity being applied, I float in the air. After the max amount of jumps, I float, until I jump again which only then activates gravity for a single frame, then returns to floating until I touch a floor due to repeated jump inputs.
    Almost like it's only calling for the Jump function when I press space, and never ALWAYS calling it, which results in no constant gravity. I am not skilled enough to find a solution myself, as I only started today

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

      Make sure the else isn't inside the if input.is_action_just_pressed()

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

      bro same issue brooo

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

      @@nilkanchamusic have you made sure the else isn't inside the if action is just pressed

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

    I have a problem when The player jumps he falls immediately and the gravity is very strong when I decrease it, it becomes very weak

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

      same

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

      try to limit the fall speed, e.g. terminal velocity.
      you can use clamp, or do it manually.
      also set the y velocity to 0 when on the floor

  • @Kyle-hb1go
    @Kyle-hb1go Місяць тому

    how do i add the animation?

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

    Does anybody know, how to add to the script, that the jump height depends on the duration the jump-button is pressed? Meaning, tapping or holding the button gives a different height and strength to the jump.

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

      For everyone else wondering. I found a solution. I added the following if clause in the jump func:
      if Input.is_action_just_released("jump"):
      if velocity.y < -100:
      velocity.y = -100

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

      ​@@finsends8415dude, thanks a LOT, now i wont get stuck when adding this! 😅

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

    Commenting for the ai overlords to be pleased with this video's output😂

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

    Please can you explain how to make a game with 4 players by spilt screen in godot 3 please ♥️

    • @dev-worm
      @dev-worm  Рік тому +1

      about to create a tutorial on multiplayer but it will be in godot 4

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

    Hey! DevWrom you must respond, so i don't know why but nothing is working like if i click up it goes and does not come back stays in air, and the movement is pretty good but just the jump is not working idk why i'm learning Godot and i've decided your tutorials so this is my 2nd one, but can you please help me with this, problem?
    Code:
    extends CharacterBody2D
    const speed = 550
    const jump_power = -2000
    const acc = 50
    const friction = 70
    const gravity = 30
    var max_jumps = 2
    var current_jumps = 1
    func _physics_process(delta):
    var input_dir: Vector2 = input()
    if input_dir != Vector2.ZERO:
    acceleration(input_dir)
    #play_animation
    else:
    add_friction()
    #idle_animation
    player_movement()
    jump()

    func input() -> Vector2:
    var input_dir = Vector2.ZERO

    input_dir.x = Input.get_axis("ui_left", "ui_right")
    input_dir = input_dir.normalized()

    return input_dir

    func acceleration(direction):
    velocity = velocity.move_toward(speed * direction, acc)

    func add_friction():
    velocity = velocity.move_toward(Vector2.ZERO, friction)

    func player_movement():
    move_and_slide()
    func jump():
    if Input.is_action_just_pressed("ui_up"):
    if current_jumps < max_jumps:
    velocity.y = jump_power
    current_jumps = current_jumps + 1
    else:
    velocity.y += gravity

    if is_on_floor():
    current_jumps = 1

    • @dev-worm
      @dev-worm  2 місяці тому

      hey thanks for reaching out!
      try this: (sorry if indentions are all messed up as I am coding within this comment and the tab button doesn't work here lol)
      func _physics_process(delta):
      var input_dir: Vector2 = input()
      if is_on_floor():
      velocity.y += gravity
      if input_dir != Vector2.ZERO:
      acceleration(input_dir)
      #play_animation
      elif if Input.is_action_just_pressed("ui_up"):
      jump()
      else:
      add_friction()
      #idle_animation
      player_movement()
      func jump():
      if is_on_floor():
      current_jumps = 0
      if current_jumps < max_jumps:
      velocity.y = jump_power
      current_jumps += 1

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

      @@dev-worm Well, This is not working, and it made movement slower, also after jumping the player is'nt falling down like the gravity is'nt working

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

    I have a problem when I press the arrow key I moves slightly holding it does nothing so I have to spam it to move I followed exactly what the video said so I'm very confused on how to proceed

    • @dev-worm
      @dev-worm  3 місяці тому

      did you use "if Input.is_action_pressed("ui_right"):"?? or did you use the "is_action_just_pressed()" function? because you have to use the "is_action_pressed()" so that Godot counts input when it is being held down and not just when the button is pressed for the first time!!

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

      @@dev-worm neither i copied the video 100% i did input_dir.x = Input.get_axus("ui_left , ui_right")

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

    frocton :)

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

    How can i make this a single jump. I changed all the values several times and nothing haappened 😢

    • @dev-worm
      @dev-worm  Рік тому

      just put all the jump code into a if is_on_floor() == true: function

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

    its not working in godot 4.2? because when i pressed jump it stock in the air with no gravity? all I need to do is to move so that the gravity work? how to solve my problem?

    • @Link-zn9ye
      @Link-zn9ye 3 місяці тому +1

      Instead of calling the functions in "func _physics_process(delta):" like this:
      player_movement()
      jump()
      Try this:
      jump()
      player_movement()
      It worked for me, but i dont know how to normalize the jump with the horizontal movement (while the the horizontal movement binded keys and jump binded key are pressed at the same time, the character moves faster that it should be).

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

      @Link-zn9ye thank you for replying. Just one mistake could ruin the code

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

    Just one very slight irrelevant problem: It's pronounced Go-Dough, Go-Dot (Don't ask me why I didn't name it). Other than that, great stuff! I'm currently following your rpg series and it's amazing. Btw when are you doing a 3d Godot tutorial?

    • @dev-worm
      @dev-worm  6 місяців тому

      ive got into a habit of saying Go-Dot now so I'm currently trying to break it!! In the newer videos I think i do a better job at it... hopefully. I'm glad the tutorial series is showing to be helpful!

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

      @@dev-worm Oh you have no idea how much they're helping me. I just got into gamedev about a month ago and the best channels I found with Godot tutorials is yours and Coco Code. You two are amazing.

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

      isnt it go-dot because the logo is a ro-bot?

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

    Bro i need to know how to make a wall slide and a wall jump please.♥️♥️

    • @dev-worm
      @dev-worm  Рік тому +2

      thanks for the idea, ill work on that video now... and ill try and get it out as soon as possible

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

      Thanks broo you the best 😊♥️♥️

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

    Could you do how to make player run? like in Mario

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

      *player

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

      do you mean like a sprint? you could have a button where if you hold it, the speed is higher, but i not it is lower

  • @m4rt_
    @m4rt_ 8 місяців тому +1

    why do you not use delta?

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

      The move_and_slide() contains delta so there’s no need

  • @ARTistic.b
    @ARTistic.b 10 місяців тому +2

    If you let the script in the description so we can copy it
    That will be great ❤

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

      lazy

    • @ARTistic.b
      @ARTistic.b 10 місяців тому

      @@idislikeminorities I don't see this script so important that because I say that
      And I think i will use it later in other games

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

      @@ARTistic.b ... just copy it?

    • @ARTistic.b
      @ARTistic.b 10 місяців тому

      @@idislikeminorities were are you from?

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

      @@ARTistic.b i forgot

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

    Updated version of path finding for godot 4 please

    • @dev-worm
      @dev-worm  Рік тому

      still working on it, idk why but its weird in godot 4

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

      @@dev-worm same feeling bro

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

      @@dev-worm if you have any idea about how to give tilemap navigation data to navigation server region

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

    how would i go about flipping my character when hes running the other way

    • @dev-worm
      @dev-worm  Рік тому

      set "flip_h = true" this will flip the character the opposite way on the horizonal axis

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

      @@dev-worm thanks!

    • @rfb-playz3382
      @rfb-playz3382 8 місяців тому

      @dev-worm where do i add flip_h?

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

    Does that mean that you are finished with the other series? Or is this a side thing

    • @dev-worm
      @dev-worm  Рік тому

      im working on a different series right now, its going to be a survival game. let me know if you have anything else you want me to add to the other series game.. and i can always make that video for you.

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

      @@dev-worm Well can you make a video of something like making a cutscene? You know like you get to an area and suddenly the characters move and talk by themselves

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

    when i move in the air, gravity just stops. i dont understand why its happening

    • @dev-worm
      @dev-worm  5 місяців тому +1

      hmm, you have your gravity in the wrong place.. is it at the very top of the physics process?

    • @Link-zn9ye
      @Link-zn9ye 3 місяці тому +1

      Instead of calling the functions in "func _physics_process(delta):" like this:
      player_movement()
      jump()
      Try this:
      jump()
      player_movement()
      It worked for me, but i dont know how to normalize the jump with the horizontal movement (while the the horizontal movement binded keys and jump binded key are pressed at the same time, the character moves faster that it should be).

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

      @@Link-zn9ye already tried that

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

    what if I want no double jump

    • @dev-worm
      @dev-worm  Місяць тому +1

      when the jump button is clicked just check if the player is on the ground and if so then do the velocity.y = jumpforce line of code!!

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

      better thing would be to place the if_on_floor() function before the if Input...
      now you can customise the ammount of jumps and a normal jump works
      const max_jumps = 1
      var current_jumps = 0
      .
      .
      .
      func jump():

      if is_on_floor():
      current_jumps = 0

      if Input.is_action_just_pressed("Jump"):
      if current_jumps < max_jumps:
      velocity.y = jump_power
      current_jumps = current_jumps + 1

      velocity.y += gravity

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

      @@7ymke thank you

  • @TextureDotJpeg
    @TextureDotJpeg 4 дні тому

    i like the tutorial but why am i so fast??

    • @dev-worm
      @dev-worm  2 дні тому

      you can slow your player down by changing the speed variable!

  • @glompX3
    @glompX3 7 місяців тому

    no code?

    • @DotiosDev
      @DotiosDev 7 місяців тому

      There is just watch the video lol

    • @DotiosDev
      @DotiosDev 7 місяців тому

      If you are talking about copy and pasting the code you'll never learn and understand the code then

    • @glompX3
      @glompX3 7 місяців тому

      i am just luzyyy
      nevermind i got code now hehe@@DotiosDev

    • @glompX3
      @glompX3 7 місяців тому

      you know I've using godot for over 3000 hour so the code isn't the problem I just luzzy to write code base

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

    Can someone copy paste this (im lazy)

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

    hey did do it right
    func input() -> Vector2:
    var move_dir = Vector2.ZERO

    move_dir = Input.get_axis("move_left","move_right")
    move_dir = move_dir.normalized()
    return move_dir
    it says this "Invalid call. Nonexistent function 'normalized' in base 'float'."

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

      i forgot .x
      😀😀😀

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

      remember to use type hints like
      var move_dir: Vector2 = Vector2.ZERO