Godot 4 Third Person Controller #1 - Movement, Camera, Animation
Вставка
- Опубліковано 3 чер 2024
- This is the first part of my Godot 4 Third Person Controller series. In this video I've covered three main topics of a third person controller system: movement, camera controls, and basic animations.
Support me: / jrouddro
Full Playlist: • Godot 4 Third Person C...
Next Video: • Perfect Jump Using Mat...
Project Link: johnnyrouddro.itch.io/godot-4...
Godot Engine: godotengine.org/
Timestamps:
0:00 Intro
0:21 Project Overview
1:04 Environment
1:21 Import 3D Character From Blender to Godot
1:55 Third Person Camera
3:30 3D Camera Collision
4:40 Using Resource to Create States
5:40 Player Inputs
6:41 Movement Controller
8:30 Change Camera FOV with Movement
9:06 Third Person Animation Controller
10:30 Outro
WHEN THE WORLD NEEDED HIM THE MOST HE CAME BACK
Hell yeah! I've been using your godot 3 third person controller as a reference a lot, awesome to see you upgrading it to 4!
Damn, he's back!
FR this year gonna be lit.
You're back man! So glad to see a new updated series from you! :)
Just got into Godot and I'm following the your 3.5 third person controller. Good to see an updated one. Looking forward to the series
the quality of production and teaching is insane, and it's all for free. thank you sm for all the time you took to put these out! cheers
you're back ! love it
He has returned! Good to see you back on the Godot scene bro. Excellent tutorial as always
Finally! Been waiting for Godot 4 after using the Godot 3 videos! Keep up the great work!
thank you, very nice to have you back
Welcome back, i liked your math explanation
This is amazing, loved your third person controller for godot 3!!! Right now i'm redoing my character meshes, rig and animations, my next step would be to try to migrate your controller but you came back with this gift. Thanks you a lot!!
Finally, Third Person Controller for Godot 4 Tutorial is here. Keep it up!
Great!
Ive been wanting you to do this one!
whoa, your comeback wasnt in my 2024 bingo card honestly
THE BEST LESSON IN THIS YEAR THANKS
Amazing work! Keep going please🤗
welcome back king
best godot tutorial for this hands down. u the best johnny and deserve recognition. but please, consider slowing down the pace of the tutorial. i found myself pausing every 2-4 seconds to understand and copy your methods. love!!
He came back when we needed him the most
Woah, actually good!
great work
You sir are a gentlemen and a scholar! thank you for doing this. It helped simplify our movement code so much!
Great to hear that! 😊
So Cool, I see that you have done a big redesign for how you script the Third Person Controller.
Now it is way betteeeer!
return of the king
Thank you very muchhh Johny
You're welcome 🙏
For anyone who is mixing his tutorial with something you already have, the is_movement_ongoing() method is a boolean for absolute speed (true if is moving):
func is_movement_ongoing() -> bool:
return abs(movement_direction.x) > 0 or abs(movement_direction.z) > 0
also, thanks for the tutorial, i'm trying working out the jump animation with the controls itself, kinda hard to nail it, but even this helped alot (even though is not necessarily about jump)
also, noticing now that he actualy point it out in the video, i must been distracted.
Well this was a rollercoaster ride XD Anyway, you can check other videos of this series. There's one with a jump system, you might find what you need.
@@JohnnyRouddro yeah, i was there, but then i choose to follow every step the way, because there is tons of concepts really new for me in this one, so i choose to follow your way to move the character to not have a massive debug process later, i'm having a little problem with the walk animation, associated with a little stutter (probably due to time of transition between animations) but really don't know yet how to fix it. Now is time for the jump video though, see you there! xD
This is a great tutorial if you already know a fair bit about Godot, it is incredibly hard to follow and goes way to fast if you're just learning Godot.
Yes his back
Awesome tutorial!
yes fr
THE BOYS ARE BACK IN TOWN
Dude you are a lifesaver Im porting my game from unity to godot and was looking at 3rd person tutorials and they all sucked
this one does it very similarly to how I had it set up in unity plus it clarified a bunch of systems to me so I could easily tweak it thank you!!!!!
Thanks! Glad to hear that I could be of some help.
@@JohnnyRouddro thanks for the tutorial it helped me to understand some systems and design principles. But, i have one question: in the editor and blendspace my stand/idle animations are playing as normal, but when i run the game these animations just playing the 1 keyframe of the animation. For example in the stand state my model is frosen on the 1 keyframe of the stand/idle animation. I`ve tried to set up these two animations as looping - it did not work. What should i do?
@@sergeyiu2301 Happy to help 🙏 I think your problem could be related to this: github.com/godotengine/godot/issues/74706 Let me know if you've found the solution there.
Hey, it may just be me, but my character just stands in air, doesn't fall, doesn't move, nothing. Help?
PLEASE keep going, I have been looking for a tutorial that actually uses components so I can understand them better, I am debating using this action/attribute system addon that just uses tags to allow or disallow actions so you can even create something like a skill tree by just adding and removing tags from an object.
LEGEEEEEEEEEEEEEEEEEEENDDDDD IS BACKKK, DAEMMMMMMMM
Hey, nice Tutorial. Tho I have one thing to correct: When you added the collision Shape to the Spring Arm 3D and told us to change the Physics engine, I noticed that I myself don't have the same Issue as you did even tho I use the Default Physics Engine! → So I assume that it is either on your end or was fixed in the newer Version of Godot?
Thanks for the info! I used 4.2.1 which is currently the latest. So, it could be something else 🤔 I'm curious. But in any case, Jolt is recommended by Juan himself and it may become the next default engine. Check this post: www.reddit.com/r/godot/s/AAbYdGgRli
YEAH BROTHER!
ohhh!! look who it is!!
Very good tutorial. Is there any way to adjust movement deceleration after releasing movement keys? Feels a bit slidey for what I'm working on.
You can increase the acceleration of the idle state. As releasing movement keys makes the player switch to idle state.
Thank you for the video. I'm having trouble with getting this to work at all though. The input is all messed up. How does the input possibly work when sprint, run, walk, etc aren't in the input map? I keep getting errors looking for those as inputs and the character will not move. Also, I'm getting a signal error as well, which I think is the issue, but I just cannot figure it out. Do you have any idea what I may have done wrong?
Are you using Godot 4.2.1?
So how would you implement stepping over small objects/stairs? have multiple raycasts to "test" the height of an object and then alter the transform of the player?
Sorry, if iths will be covered in future videos.
I haven't given it much thought. Added to my list. I'll work on this after I'm done with other videos. Thanks for the comment 🙏
This couldn't have come out at a better time!! I just started making a third person shooter in Godot 4! Will you be making a shooter version with aiming like you did for Godot 3?
Aiming, Strafing maybe included in this series. I'll prioritize RPG mechanics after this, melee combat and all that. Then hopefully I'll do the shooter.
Gran videos, hace un mes vi los videos viejos y logre pasar todo a godot 4 pero tenia ese error en las camaras, probando jolt pysics se soluciono pero creo que no se pueden usar los raycast
5:52 Just wondering, isn't _unhandled_input() better to use for game play input? (awesome video btw)
Great question! The input being handled or not is relevant when you have the same input for multiple nodes, say a pause menu uses left click as well as player's "shoot" function. In that case, you use unhandled input for the player so if the menu uses the input, the player doesn’t. More details about this topic in this comment of a reddit post: www.reddit.com/r/godot/s/gAkGpphasl
@@JohnnyRouddro thank you for the explanation!
if you set the margin higher the camera will stop further back from the wall, should keep it from clipping into the wall better
Is there a reason to put camera rotation inside _physics_process(delta)?
For me it results in some sort of camera desync which looks like low fps. Putting camera rotation code in _input(event) for example looks a lot better in game
For precision shooter games the camera code can be in the _input(event) function. For general 3d platformers the camera may need smooth motion, where the physics process comes in handy. I myself didn't face any issues with this tbh.
In the project overview, which software do you used?
drawio. It's super cool and FOSS.
Hello, any idea why the fps is bad when i run the game on a macbook m3? is it some setting i need to tweak or an OS issue what do you think?
I'm not really sure. Could be because of the Jolt physics engine.
Hi johnny hope you doing well, Can you elaborate the animation controller with key switch like idle, run and etc.
Hey there. The animation controller receives a movement state, and passes the animation id to the animation tree. Then the animation tree sets the value of the blend space to that id.
@@JohnnyRouddro Thanks for you instant response. Although i figured it out. by slowing down your video :D. Thanks again. keep doing good work. May god bless you.
Are you taking requests brother? Would like to place a request for root motion and ik blending for the tps controller (climbing, interacting etc.) But please, do whatever you want with it. I'm just happy to see you after so long 😢
Thanks 🙏 I'll keep it on my list.
Don't use Jolt physics from Asset library, just set your Player node to the other layer than SpringArm is. It will prevent camera clipping inside the Player.
The issue is not actually clipping, the SpringArm is jittery in Godot Physics. It's noticeable when it collides and slides on a wall/floor surface.
at this point, may i ask you if im allowed to use the code you provided (only the code, not the assets) as a starting template for a small project of mine. its well defined and doesnt need any refactoring.
liked and subscribed :)
It's completely free for any use. Project link: johnnyrouddro.itch.io/godot-4-third-person-controller You can also follow me on itch to see bugfixes and updates on the project.
@@JohnnyRouddro yeah thank you very much, stuff like this really boost beginners in their making. thanks again!
@@timoschmitt8317 It's my pleasure 😊 I myself am learning and growing with these videos.
Hm, the animation could use some tweaking since neither shoulders nor hips do anything when running but the model is pretty cool. Quite motivating, actually.
Hello. Very useful video. But is it possible to do this in C#? I'm having big problems with signals in C# using your logic. Are there any plans to make a similar video for C#?
Hey there! Tbh I haven't yet tried C# in Godot but I can see the increasing demand. I'll add it to my to-do list, but it could have some delay as I need to cover other hot topics first. Thanks for bringing it up 🙏
Thank you very much! Will wait. It seems that I have almost transferred your project to C#, but there is one problem that I cannot solve for a long time. I'm new to programming, so some things are still difficult for me.
@@JohnnyRouddro Today I managed to transfer your project to C#! I can send it if you are interested.
@@DarkDaimos I would like to get this file too please :D
Hey! I have a quick question.
Do you suggest doing the animations in Godot or Blender? I made a simple animation in Godot, and it works, but I see most people doing the animations inside Blender.
For 3d character skeleton animation, blender all the way. Godot is not designed for skeleton animations. Blender on the other hand, has all the necessary tools for animation.
@@JohnnyRouddro ohh alright, yeah, I made the hand animation but it was simple, so I'm guessing simple animations can be done on Godot, while "advanced" animations are done in Blender.
I recommend that you do everything through Blender. In Godot there are problems that if you want to reimport the model, the animations you made in the engine are lost.
@@mark-moon3822 ohh, gotcha, thanks!
Well come back again
Movement states doesn't show up under the research tab when I search, not sure if anyone knows why. >> (appreciate it)
Save the script changes.
Then try searching. It had worked for me that way.
Make a tilt/lean when turning tutorial please
Will you ever implement root motion in your tutorials?
Well I do have a big list now, and root motion's right at the middle 😄 Gonna cover the popular topics first.
@@JohnnyRouddro appreciate it 😄
Hi so when I tried moving the character it's moving in the opposite direction of the key press (W become backward, A become right etc) but the character facing the correct direction. I already double check the code from the tutorial, I think I'm missing something.
Not really sure why that's happening. Maybe do a temporary fix in the movement_controller script where velocity.x and velocity.z is assigned, and make them reverse.
@@JohnnyRouddro Alright thanks that fix it, but I need to ask again, since I'm using my own state system with State Charts addon, I decided to delete your movement_controller signal to states, then temporarily assign the speed and acceleration to a float variable directly written in the script (but the same value as in the movement state), however the character keep moving (actually accelerating to it's maximum speed value) even after I release the button. I thought I'm messed up in the player script, but when I'm connecting your state system back it's not happening. What could be the issue?
Sir I have few questions is that how do i modify the script like give him aimming system or vaulting system
Thanks for asking. Aiming + strafing will be covered in this series. Vaulting/parkour needs its own series. I'm planning to use this third person controller as a base for multiple other projects.
@@JohnnyRouddro ThankQ soo much sir
5:47 bro chilllllllll i blinked and your speaking a whole different language where does that go broooooo
😂
Watch beginner tutorials as I said earlier. Godot is very beginner friendly. If you keep at it, you will reach intermediate level in no time.
i have a problem, when i walk,run or sprint the animation play for 1 second then it freeze the animation but i can move
Probably the animation is not looping. You can have "-loop" as a suffix of the animation names so Godot automatically makes them looped when importing.
@@JohnnyRouddro Yeah, it's works on me!
Thanks a lot man!!!
You just have to reimport the model by replacing it and that's it.
👍👍
ThankQ sir soo much,
I see you found a new method to make third person controller system please do teach us more and I just want to know is that where do you learn new systems and coding like that ??? 🤔
BTW I admirer you teaching us please keep it up
Thanks a lot! Let's just say, I've been pretty busy for last 3 years 😄 Had a lot of personal growth. Hope I can make quality stuff from now on.
Noob here. This is easily expandable to include combat states/functionality/animations? Seems like a great baseline for me to mess around with! Thanks!
You're absolutely right. In fact I am using this one as a base for my next tutorial series which indeed has a combat system.
Good video bro but I need a favor, please, please could you please make a video on how to create a fighting game in godot engine 4.2, I really beg you, I really need it, I would like to start video game development with that and make it a fighting game. game 2.5D
I’m a bit confused, I tried putting the third person camera into my game although it doesn’t rotate around the character and instead just rotates around itself. Great tutorial though keep it up
Nevermind that was me being stupid, my camroot it was inside of my camera
Being stupid is the first step towards becoming highly skilled. Glad you could figure it out 💪
The camera script is a little confusing to me I want the free movement 3rd person camera, But I also don't want to just copy code when I don't know what I'm doing.
It's true that yaw/pitch creates confusion, I myself struggle to remember what yaw and pitch is. I just tell myself "yaw" is "no" (nod left right), and "pitch" is "yes" (nod up down). Having pitch node as a child of yaw node makes it easier to have a gimbal formation. Think of it like this, you're wearing a 1980's batman suit, and you can't turn your neck left/right. You can only turn your Body left/right, and your Head up/down, thus covering the whole 360 sphere. In this case your body is the yaw node (Left/Right), and your head is the pitch node (Up/Down). Now write the script to do exactly that for each node's local axis and you're good to go.
@@JohnnyRouddro thankyou for the reply! I did end up understand more after messing around with Godot myself.
I was trying to make the character face the direction of the camera on my own, and found out how pitch and yaw worked. I couldn't figure out how to get the yaw. Rotation to the player since I separated them to two different scenes. So i went back to your video and I seen you helped out with that too so thanks a lot!
The state machines really confuses me so I stopped watching. even though that's the only thing I really feel is holding me back from making any game. I want to make a state machine but they are always so confusing.
I like the way you used resources though. So I might end up frankensteining that state machine with different one because that's a lot of code in one block.
The way you are figuring things out on your own is the best way to learn imo. You can make the entire control system without any state machine, just like I did in my third person series from 3 years ago. Try to make what you want with knowledge you already have. You WILL eventually hit many brick walls coz that's how game dev is. That is the perfect moment to learn new techniques, as you will see real life use cases.
Please Johnny,
I'm following and adapting your code from the begining and I'm very gratefull about it.
I begun the adaptation from 3 to 4 Godot version myself, (discovering the spring arm, and all that), but my results weren't aceptable...
Thankfully, you begin this Godot 4 fully rewriting.
I would like you use the following, for minimizing our code diferences:
May you use directly the blender file, as the version 4 manages it as native, and don't use import/export gltf....
I'll apreciate it very much, as I'm doing the same player controller, and like to use your series as a guide.
I'll also apreciate if you explain detailed what animations you used. I think is very interesting to do all the blender character definition "portable" for changing it to other characters, without changing code and (I'll desire it) animations.
Thank you, very much, for saving me so much time.
Thanks for the suggestion. Using any character for the same movement controller could be an interesting video. I'll keep it on my todo list 👌
Hi Johnny, I also discovered textured may use webp format (a magic format mix advantages from jpeg and png , used natively by blender and godot4)(at 1/6 the size of a png...) interesting for performance.
Thank you for answering me. Best Regards.
I want to replace the model with another one, but have no idea how. I'd like to pull the model out, put it into blender, replace it while keeping the skeleton, then put it back in with the new model. Anybody know how?
You can import the glb file in blender. There is a T pose animation, so if you have a T pose mesh, you can easily reparent with the skeleton (you'll can select the "automatic weight" option). And if the skeleton's body ratio matches your mesh, the animations should work properly. Otherwise you can modify the skeleton in edit mode to fit the mesh.
Or you can rig your mesh using mixamo and use new animations. Maybe I can make a video on this topic soon.
@@JohnnyRouddro thank you so much
8:56 What's going on here? Why so fast?
Oops! I forgot to say I was connecting the "set_movement_state" signal from the player script to the "_on_set_movement_state" function I just created. Thanks for pointing it out.
So godot 4 has gotten bette at 3d? Its not on par with unity or unreal yet is it?
Godot in 3D offers more than enough for an indie team. However, if you wanna make RDR 3 and have a 10 year long development timeline, go for a proprietary engine 😄 Although in 10 years, Godot will be dominating, so RDR 4 can use Godot.
@@JohnnyRouddro 10 years? Peopel take 10 years to develop games now?
@@JohnnyRouddro I do like that the code is Intergrated so it's easier but I'd have to relearn a new language and I just started to understand c#
You can learn whatever engine makes you feel comfortable. You can transfer the knowledge to other engines when needed. Game engines are just tools. To make a great game, the true power lies within the developer.
Please implement a target sytsem
Thanks for the suggestion. Camera targeting tutorial will be included in this series.
I’m having some issues following along. You go pretty fast and don’t really explain anything. I constantly have to go back and pause to see what exactly happened on screen, which isn’t easy because you often fly through everything. It’s cool that you can do this really fast and all but you’re making a tutorial, it should be easy to follow along and understand what’s happening. It would also be cool if instead of having the project files for just the finished project, if you gave the files for each leg of the series. If I want to make sure my code is what it’s supposed to be, I can’t look at the project files because you change and replace things along the way. So I end up having to find a spot in the video where I can see your code which isn’t ideal. Anyway, love the videos and thanks for making educational content.
Thanks for giving such detailed feedback. I myself have a lot to learn in the tutorial making area.
movement is reversed and i cant figure out why, made sure theres no rotation on the model, or in the imported scene, foward goes backwards and right goes left, the model turns to face the movement directions correctly, but the controls are always reversed
Hi!, the same thing happened to me too.
It turns out that I solved it if you rotate the CamRoot 180 degrees.
So now, the character will rotate correctly with the movement.
It worked for me, and I hope it works for you too.
@@mark-moon3822 that didnt work for me, but i found a fix by reversing the order when getting the input strengths, if you put "right" - "left" and "back" - "foward" instead of in the opposite order, it reverses the movement you get
@@christiandelao2547 By the way, if you have problems with the animations part that freeze, you can in Blender put -loop at the end of the name of your animations. (Similar to when you put -col for collisions on imported Blender scenes)
@@mark-moon3822 i guess theres actually a bunch of those, like -wheel and -vehiclebody, havnt gotten around to trying them all out yet, but their supper handy
@@christiandelao2547 Yeah. Just one thing, don't add -loop to jump animations (Only add -loop in the falling). Well, when your character reaches the floor, it will repeat the jump animation.
Wow this is going to be hard from a 0 experience noob like myself😂
I don't think the _physics_process is working I did the first two lines and tested like you did and it just crashed on me😢
🤣
I highly recommend watching some beginner tutorials first. There are plenty on youtube. I am focusing more on the 3D intermediate level. Be patient and watch+make beginner stuff, I hope you will get there very soon.
You can download the entire project for free and see how things work first hand. johnnyrouddro.itch.io/godot-4-third-person-controller
@@JohnnyRouddro i did but im also on a phone xD i did managed to get it to work via comparable mode but the level was so blinding im making steady progress and learning alot on the way
Promo sm
Default physics is so shit.
terrible tutorial, you skipped over so many steps
Thanks for your feedback. Would you please specify which steps could use more elaboration? I hope I can learn from this and make my next videos better. Thanks 🙏
@@JohnnyRouddroyou do skip over things. Like you will do something off camera and then it’s just there and we’re have to investigate. Like there will be new code and you don’t explain where it came from why it’s there, nothing. For example 8:15 you create the cam_rotation variable and a corresponding function and don’t even acknowledge it.
@@DuhglessFunnie Noted. Thanks for pointing it out. Will try my best to improve these things in my next videos 🙏
@@JohnnyRouddro I want it known that I disagree with notcarbuncle. I think this is a great tutorial. I really only wish your tutorial were longer/more in depth.