Godot 4: 3D Character Controller

Поділитися
Вставка
  • Опубліковано 14 жов 2024
  • In this series of videos, we look at how to import, setup, and use 3D models in Godot, whether you downloaded them or created them yourself.
    You can download the art packs we're using from Kay Lousberg at itch.io:
    kaylousberg.it...
    Text version and link to code:
    kidscancode.or...
    Want to learn Godot 4? Check out my new book, Godot 4 Game Development Projects.
    Available now! amzn.to/3qcOZ4E
    Support me on Patreon: / kidscancode

КОМЕНТАРІ • 77

  • @eugeneivanov353
    @eugeneivanov353 11 місяців тому +14

    Your last 3 videos are amazing! Reignited my interest in game dev! Thank you and I hope you continue to make more guides like these!

  • @emmanuelfrion2640
    @emmanuelfrion2640 10 місяців тому +5

    Thank you!!! I was having a lot of trouble understanding how to correctly rotate the camera towards the direction of movement in Godot 4 using a CharacterBody3D. You made it very clear and simple, nicely done!

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

    Happy to see you back! Thanks for the great content as usual.

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

    Yesss. I bought also kaykit extended edition of the characters and more of them. So ready to do my RPG in godot

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

    This is my favourite channel!
    P.S can you make a tutorial for a plane simulator, but in godot 4.1 or 4 please

  • @Xorked
    @Xorked 6 місяців тому +1

    Wish you would keep going with the series, good job

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

    So cool, glad you are back. Any chance you can do a follow up for game pad controls? Converting the mouse to thumbstick is always confusing.

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

    Thank you so much!!
    For some reason my Godot wasn't able to reliably grab the default gravity variable, so I added 9.8 to fall back on:
    var gravity = ProjectSettings.get_setting("physics/3D/default_gravity", 9.8)
    I have a lot to learn, your videos are really helpful!

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

    What a great series! Thank you so much! 🙏🙏🙏

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

    When's the next episode coming?

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

    Finally! Thank you!

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

    Thanks for the video lesson, is there a sequel on UA-cam or somewhere else, or is this lesson frozen?

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

    I learned python from you, now its time to learn godot from you.

  • @CoolCode-t2t
    @CoolCode-t2t Рік тому +2

    I like your work sir, it is awesome

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

    I'm hoping you're planning on still making more videos, they are a great help!

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

    no new procedural generation tuts? loves the 3 vids btw

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

    Brilliant! Thank you so much!

  • @varglbargl
    @varglbargl 8 місяців тому +2

    there's this part like 3 videos ago when you're first importing the knight where you were like "yeah and like some of these animations need to be looping like the idle and walking ones and whatever okay moving on" that i feel like you should have been clearer about. As soon as I saw it I was like "I'm definitely gong to miss one of those and it's definitely going to screw me later" and so here i am, screwed, obviously.
    Basically, how do I set the "Jump_Idle" animation to be looping from this point in the process?
    Last time I tried reimporting the knight it wiped the entire animation tree out of existence and plus you never actually said what the correct settings were in the first place so I'd just be guessing again.

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

      For you and anyone else that reads this. You need to reimport the animations and set the loop mode to Linear. Click on the Import tab (top right) then select your resource (Knight.glb) you may have to click on another file first and then back to it. Then in the Import screen click Advanced and a new window will open up. Scroll down until you find your animations and all the ones that you want to loop click on them and then in the top right where it says Loop Mode set it to Linear. Once done for all animations that you want to loop, click Reimport and you are done.

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

    Thank you

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

    Hi! Great tuotrial! One question: How I could blend the attack and walking animation, so when I walk and attack the upper body plays the attack animation and lower plays walking animation? I've tried with BlendTree but it didn't behaved very well...Thanks!

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

      In BlendTree, you can use a Blend2 or Sub2 which have a filters list, where you can choose which bones you want to use.

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

      I was looking for this but I cant figure how to do it exactly. Can you elaborate please ? Thank you so much
      @@Kidscancode

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

    I have set up my animation tree, but now I want my idle/walk animations to loop. Is there a way to set this up on the animation tree? I have the animations set to loop in the Animation tab, but they aren't looping. Any tips?

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

    Great tutorial man! Hope you can also create a virtual joystick for mobile related to this! Thanks!

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

    So cool, thank you very much. Looking forward the next videos.

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

    Hi, great tutorial, very clear. I am just having trouble with the model.rotation.y. when I have this
    if velocity.length() > 1.0:
    model.rotation.y = lerp_angle(model.rotation.y, spring_arm.rotation.y, rotation_speed * delta)
    it's working, but my whole character flips 180 and then works. Im not sure exactly is happening

    • @matzi-dev
      @matzi-dev 8 місяців тому

      Idk if you already fixed it but you may have rotated the Rig node 180 degrees, but is the Skeleton 3D that must be rotated 180 degrees. Just reset Rig rotations and apply 180 degrees to the Skeleton 3D.

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

      @@matzi-dev Hi, I've had the same problem and resetting the rotation of the entire model and rig didn't work. What did work, was to put the velocity.length() in the negative. So, it looks like this:
      if -velocity.length() > 1.0:
      model.rotation.y = lerp_angle(model.rotation.y, spring_arm.rotation.y, rotation_speed * delta)
      I don't know why though!
      Maybe it helps someone else in the future! :)

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

    Any chance you can create a video with mobile controls or explain how to get them working?

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

      I suppose, but there's really no difference to the character controller. The movement of the character is the same, the only difference is what produces the input action/event. A screen tap is the same as a mouse click, for example, so click-to-move and tap-to-move are the same thing.

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

    Is it better to have all your planned animations for the character done before starting controller or is it easy enough to just keep adding animations as you go?

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

      That's a design question more than a controller question. You should already know what you want your game to play like before even construction. List all the actions you want the character to be able to do (ie walk, run, jump, roll, attack, dodge, block, etc). Then you can make your character and their animations. What you set up in Godot is merely what key presses (or console controller buttons) will activate which action.

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

    Everything is working except sometimes I have to click the left mouse button a couple of times before it performs the attack animation. How would I fix that?

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

    Amazing thank you

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

    Getting an error. The error is "Invalid get index 'transform' (on base: 'null instance')." It has a problem with a line of code under the function "func get_move_input(delta):" it doesn't like the line "var vl = velocity * model.transform.basis".
    Any ideas why?

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

    Theres a little delay when you hit the space button and start jumping animation(player is already on air when animation starts). Wich is the best way to fix this?

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

    I'm not understanding the script keeps telling me "get_move_input" not found in base self

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

    I really like 2D games, but 3D games seems to be more easy to do because you don't need to make sprites for every state in every angle.

    • @Kidscancode
      @Kidscancode  Рік тому +7

      Animation can be even more challenging than drawing sprites.

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

      animations take wayyy more time than drawing sprites, especially when pixel art is used in 2D. Collision tests can be more tricky too.

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

      In 2D there are only few select angles, but in 3D you have to make the animation look good from all possible angles.

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

    thank you so much! too bad there are no more tutorials

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

    so whenever i start the game and move around, the camera turns the the right of my screen instead of forward in the camera direction how do i fix this?

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

    does anybody have the complete scene file for the knight? for some reason mine isnt working, and i cant figure out where the problem is.

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

    How would one adjust this code if they don't currently have an anim_tree setup?

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

      Currently running into an issue where after moving the camera even a little bit, strafing left and right or forward and back moves me in sort of an ellipse. But this doesn't happen if I run the scene with the mouse outside of the window. Strange.

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

    My player isn't turning in the directions of movements and only idle animation is playing when moving. Interestingly all the attack ones work fine. The jumping works but turns to face forward if I'm rotated at all (though it has a little bounce/hop at the end??). They all work in Animation Tree preview as expected. No errors or debug log errors. I think I have all the code correct, but without a place to check the code, I'm stuck. I started with the text tutorial but it isn't clear where to add a lot of the code. In the video, I paused at all the script frames and checked, and I now have the lines placed correctly according to this video. It must have to do with Rotation and calling the 2D Blendspace for Idle/Walk/Run? What am I missing?
    Here's my code for that part:
    func get_move_input(delta):
    var vy = velocity.y
    velocity.y = 0
    var input = Input.get_vector("left", "right", "forward", "backward")
    var dir = Vector3(input.x, 0, input.y).rotated(Vector3.UP, spring_arm.rotation.y)
    velocity = lerp(velocity, dir * speed, acceleration * delta)
    var vl = velocity * model.transform.basis
    anim_tree.set("parameters/Locomotion/blend_position", Vector2(vl.x, -vl.z) / speed)
    velocity.y = vy
    func _unhandled_input(event):
    if event is InputEventMouseMotion:
    spring_arm.rotation.x -= event.relative.y * mouse_sensitivity
    spring_arm.rotation_degrees.x = clamp(spring_arm.rotation_degrees.x, -5.0, 5.0)
    spring_arm.rotation.y -= event.relative.x * mouse_sensitivity

    • @Sandyy_sandy
      @Sandyy_sandy 3 місяці тому +1

      at spring_arm.rotation_degrees.x = clamp(spring_arm.rotation_degrees.x, -5.0, 5.0)
      it should be spring_arm.rotation_degrees.x = clamp(spring_arm.rotation_degrees.x, -90.0, 30.0)

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

    I'm getting an error when using travel on the animationtree to get to the jump idle animation. Any idea what could cause it?
    The error: "Invalid call. Nonexistent function 'travel' in base 'AnimationTree'."

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

      That's because you're calling it on the wrong object. 'travel' is a method of the AnimationNodeStateMachinePlayback, not of the AnimationTree itself. You should be calling it on the object you got with `$AnimationTree.get("parameters/playback"), as done in the example.
      You can also see the docs for further details: docs.godotengine.org/en/stable/tutorials/animation/animation_tree.html#state-machine-travel

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

      @@Kidscancode Ah I see what I did wrong. Also accidentally left an extra slash in the string parameter for the state machine.
      Thank you very much!

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

    Good to see you back sir! Some feedback about your mic sound: there is some boominess in the low freqs (maybe your room doesn't have much acoustic treatment or too close to the mic?). Maybe you could add a high pass filter from 0 to 80-100 dbs, or raise a few dbs on the high freqs. A mild compression may help too. Hope it helps.

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

    Please enumerate
    The videos of this series it pretty hard to follow them in order

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

    Help? Keep getting the error "Invalid get index 'rotation' (on base: 'SpringArm3D'). Referring to a line of code under the function _unhandled_input(event):, the line of code it doesn't like is "spring_arm.rotation.x -= event.relative.y * mouse_sensitivity".
    Any idea why? Could it have something to do with the version I'm in? Am in 4.2.2
    EDIT: FIXED.
    Had a somewhere that needed a comma, and another that needed an equals sign

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

      its probably because they dont coincide
      make sure you have the code for spring arm in the variables section
      so it should be
      var spring_arm_3d = “what ever you have”
      so when you write it in the code for the camera movement make sure the variable you set spring_arm_3d is spelled the same through out the code

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

      @@THEDEVBOIS I wish it was, unfortunately all is well on the side of spelling... thank you for trying though, might try a simpler camera movement code, but fingers cross the comment gets seen by the channel

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

      Hey there. After a quick look on Google, it might be because you've placed that line in a part where it should not be. Or maybe you used @export instead of @onready. Don't be afraid to look up those kind of errors on Google, they usually have good answers :) Good luck!

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

      @@redelixir9384 Hii, thanks for the advice & stuff. Unfortunately changing the mouse sensitivity from "@export" to "@onready" caused a separate error, plus an one. And I've had a peak, the line of code is in the same place in the video. Thanks for trying anyway, always nice to get a reply :) I'll keep tweaking, and try searching about the web as you suggest. Thanks again

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

    Can you port your godot 3 projects to godot 4

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

    im having a small problem and i dont know what it is the system wants
    on the
    if velocity.lenght() > 1.0:
    if i have 1 indent on the if statement and 2 indents on the next code with “model” i get this error:
    cannot find property “lenght” on base “Vector3”
    when i have 1 indent on the if statement and 1 indent on the model code i get an error saying i need an indent??? even though i already have one💀
    but when i have no indent on the if statement and 1 indent on the model code i get 3 errors
    1. unexpected if statement in class body
    2.unexpected indent in class body
    3. expected end of file
    like bru i already tried 15 hundred ways and idk what it wants any help

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

      Hi there, hope this helps. It's a spelling error of the word 'lenght' . I know this because I made the same error :') It's spelled 'length' , the 'th' like you'd say 'the sixth' for example. Good luck! :)

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

      @@redelixir9384 i figured it out awhile back now uh days im trying to figure out how a shooting mechanism works and for some reason its actually hard😂😂 its harder than figuring out how to make my player crouch.

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

      @@THEDEVBOIS Oh shoot, came in late. Oops! Maybe it will help others in the future xD Oh. Man.... I haven't even started on the shooting part... Oh well. One step at a day! Good luck to you though. I'm dreading that part now :') *sigh* more programming :(((((

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

      @@THEDEVBOIS Btw, did you happen to have a problem with the animations not triggering, more specifically the 'Jump_Idle' one? I mean, the jumping animation works at about 10% of the time..

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

      ⁠​⁠@@redelixir9384lmao ur all good😂 and the jumping was working for me perfectly if your having issues with the jumping double check the arrows that go into the next animation. because i faced an issue where i jumped once and it worked but when i jumped again it was in a constant jump loop. i fixed it by double checking the arrows that go into the next animations and i also looped the jump animations which i shouldnt have. the only thing that should be looped is the jump idle.

  • @marc.lepage
    @marc.lepage 6 місяців тому

    If you miss just the right steps, you get a Jamiroquai video.

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

    What about ai?

  • @qwatik
    @qwatik 7 місяців тому +4

    nothing in this tutorial works except making the animations

  • @Gaadiya-x-edit
    @Gaadiya-x-edit Рік тому +1

    Bro the script is not working on mine laptop

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

      I had the same problem. Changing
      func _unhandled_input(event): to func _input(event): fixed it. (not sure if this helps your problem)

  • @md.salmanahmed3903
    @md.salmanahmed3903 9 місяців тому

    bro make control for android plz

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

    Make a tutorial for a star wars game