This tutorial was exactly what I needed to understand how the animation tree conditions worked! It just wasn't clear to me that adding a condition to a transition resulted in a new property on the animation tree node. I really appreciated the starter project so I could get right to the details of the tutorial. Some critiques on the video 1) You could remove the manual "lookAt" code that makes the camera point at the head of the character if you set the controller (and by extension the spring arm's origin) to the same global position as the "lookAt" node in the controller's code - then the camera will naturally point at the place that you want without making manual adjustments to the camera's rotation 2) the state machine could be drastically simplified if you inserted a 2d blendspace for the walk/strafe animations instead of inserting all of the animations directly, then the walking logic can be handled by a single set of transitions and the animations will blend seamlessly between walk and strafe
Hey thanks for watching also, thank you for the critiques! I actually do number 2 in my root motion tutorial I didnt think about using it until my c# version of this tutorial! As for 1 ill have to look at it.. I think I do something similar to this on my root motion tutorial as well but I don't remember..
Excellent tutorial in third person, very good!. I hope you continue another one: where the character executes actions by touching objects, for example, climbing on a box
About the rotations, in code they're expressed in radians. So @11:44, -1 actually means 60° (PI/3) and is above the character, while 0.25 corresponds to 14° close to the ground.
I'm an absolute beginner so I really appreciate this! I was trying to learn another character controller one and then add my own stuff to it (bc I want to try to do stuff on my own at least for practice in between tutorials? So I'm not just doing tutorials I guess to begin xD but someone was coding the movement manually instead of using state machines and state machines is SO much easier holy heck. The jump and fall was driving me crazy because of an locked/unlocked animation situation. So greatful for this
For all newcomers like me: 40:30 I think a clean solution is a blendspace 2d node for all walking, strafing and idle animations. I use blendspace 1d for my character because I don't need strafing and it works very well. And maybe we can put the jumping/falling stuff in a seperate state machine node, but I didn't try it myself. Thanks for this tutorial, it helped me a lot!
Hey Welcome! I hope I can help you out! Let me know if there's any topics you think would be good to be covered and ill be more then happy to look into it.
if you are having problems with the lerp section, what i did is I changed .05 to 4.2 * delta and also I put the position of the LookAt node in camera controller to -400. I dont know if this is good practice or a good solution but it works much better than before. I also have the y position of the LookAt node in camera controller to 2(around the same height as my characters head)
That does seem like a good solution when i did that i ran into issues with jumping and my character would learp slow although you should multiply by delta which is something i missed
Thank you for sharing your Godot 4 game engine online tutorial it has been a big help for me to get started on my indie Game development journey with Godot 4. Please keep up the good work doing the online tutorial.
I would love if you could do a video of how to set it up the character in blender and if you could add in a way to go from first person to third person view. really great video though i am learning a lot from your channel so thank you so much.
Instead of running LookAt every frames, it is better to set the spring arm global location to the Node3D target in the Player Scene during _Ready() to get the same result with less runtime calculation
Are you able to describe your learning process, basically how you learned how to make things in Godot? I’m trying to figure out how I should approach things since of course this stuff is very difficult. My idea as of right now is to continue following tutorials until I have some understanding of what tools I have to use and try to create little mini games with them. I’m not sure how effective this method is, and it’s certainly hard to keep myself motivated with the frustration of not knowing anything. Either way, I’m curious as to your approach and I would like to see if I could apply your methods to my own.
My approach is to just keep trying new things. What really helped was breaking down my problems into smaller sections and then researching those small sections. Coding things in a very reusable way is something that comes with time so you're going to have hundreds of projects that are not well put together. Most of my projects today are still not well put together lol
Everything in the tutorial seemed to work great. Up until the lerp section. Not sure if I did something wrong. But now the player only wants to look at center of map. Before adding the lerp code the player followed the camera properly.
jesus that animation state machine is crazy. I could image it being really useful for smaller things but anything with interlinking transitions is just crazy. Would be unmanageable if you added more.
Nice video! I personally prefer putting the camera under the player scene using a pivot + spring arm (as you did) and putting the mesh / collisionshape under a node within the player tree so turning the character(mesh/shape) doesn't rotate te camera. I would love to see you do a tutorial on your view on using concurrent state machines for things like attacking while jumping, running etc! Oh and a fun thing that instantly adds a little more immersion is to put the LookAt (or the pivot point of the spring arm) a little in front of the character's face! It will give you more feedback when turning your character (A little trick from deconstructing Kingdom Hearts' character controller)
Great video! Could you make this kind of 3D tutorials with C# or make a C# version, C# is really better when you make a 3D game on Mobile platform, thanks!
I am currently editing this video for C#. Every video I do I try to do a C# version. That being said Godot 4 C# does not support mobile yet so id keep that in mind.
@FinePointCGI To avoid the animation spaghetti I added separate straifright and lefts to the idle …. I don’t think the tree stops you from having an animation state more than once, so idle can go to its own set of strain right left falling etc… kind of a mirror of the walk and it’s straif left right and falling. Am I being clear? great video btw… I am new to Godot and finding your videos have helped me a lot.
Your probably correct however I ran into issues with having it properly transition state. I'm sure I'm missing something but that's why I didn't use it
I can’t really help you there but I know Devmar has done a lot of work with them in Godot 4 and you might be able to glean something from his videos or reaching out to him
You're right it's easier because you can put 5 animations in it (walk at (0, 1) and (0, -1), idle at (0,0), straifleft at (-1,0) and straifright at (1,0) and set the blend position with input_dir in the script : $AnimationTree.set("parameters/Walk/blend_position", input_dir)
Has anybody else noticed that when the character strafes he moves forward slightly? How do I make this work so that my character will strafe perfectly left and right? Is it a problem with radians vs. degrees?
I should have looked at your more recent ones first lol...but this seems like a good start and learning (I'm switching from Unity back to Godot). Thank you for this! @FinePointCGI I still can't get my actual player to turn left/right depending on direction he's moving. I don't know what I'm missing. I copied your code to be sure I didn't have a typo, and I didn't. The mouse rotation does also rotate the player somewhat, but he never "turns" right or left. I don't want to strafe, so I'm not including that part. I have looked and can't find anything on just that one part of "turning with movement direction." I'm sure you're busy but if you could reply with a quick word on how to separate the x to make the player turn right/left I'd be forever grateful. Notes: 19:43 Alt F4 may not work on Mac dep on settings, so Command-Q will get you out of the game preview. Of course that quits it and you can't just refresh after--have to play from scratch. I think before we set up that feature, we should set up ESC to release mouse control? That was a panic moment being locked in game with no "escape" lol (and don't say use PC lol). Really had to play with LookAt[Cam] positions (1.5 on Y and -7.5 on Z) and SwingArm (.5 on Y) settings to get Player to not look below floor. The script settings only seemed to limit its view ABOVE the floor, but not below. Also 'Character character in CameraController Script wouldn't work...had to change Character to CharacterBody3D - CharacterBody3D character (guessing bc the player script says "Extends CharacterBody3D" at the top?). I asked Chatbot for "In Godot 4.1 3d, my camera looks below the floor. how do I limit its tilt" and it gave me Max and Min PITCH. Thoughts on this option? Seems much simpler to put it halfway up the player then use pitch than all the stuff here. In 4.1 I cannot change the advance condition...it's showing & sign and won't let me edit it. I can't keep going in your tutorial until I find the cause of that and I cannot even after an hour of searching😕 EDIT: AHAHAAA I had the window squished so I could see RUclips & Godot at the same time...so the actual text window after the & wasn't showing/clickable. WOW. That's an hour of being an idiot I'll never get back lol.
how would you do a blendtree of this? i have a first person character controller with some animations mapped to the left and right, as well as forward buttons for view sway and i wanna blend between them as i'm strafing
Все супер, только из-за функции lerp() мой персонаж подергивался во время бега (он иногда поворачивался на 180 градусов вокруг своей оси). Заменил на lerp_angle() и проблема решилась🥳🎉. Спасибо за видео.👍
Thanks for great video. I tried to add an attack animation, just saw that attack animation always runs , how can I set attack condition to false after attack finished? I tried animationtree, animation_finished signal, for some reason , animation still fires twice.
Thank you so much for this tutorial. But do you know how to assign button inputs to animations? I followed the tutorial but I'm not sure how to make my player's animation for attack to play after pressing the "B" button.
i kept getting Parser Error: The identifier "global_position" isn't declared in the current scope. , though i thought i followed everything correctly :/
I plan to add vaulting climbing running sneaking and adjusting the character system to only look at a place when you lock on. I may also add dodging as well
You mention pretty early into the video how you were able to collapse the animations into just one in blender - do you have more material explaining that a bit more in depth? I am very comfortable in blender, but have done very little with exporting animations out of there.
Hey i love the fact that this actually manages to work as all other one failed to work on mobile, however i noticed that when i jump my character will do this rocking motion. I looked through the code to see if maybe i mess up somewhere but it seems to be right. a small adjustment i made was to move the LookAt node very far but this can make thing harder for levels i fear later down the line as the character still tilts itself in the air. do you know how i can completely lock the axis of the player to prevent this using your camera set up/script?
Around 21:00 minutes, adding the look_at() function, when moving the camera up it causes the screen to flicker and spams the error: "Up vector and direction between node origin and target are aligned, look_at() failed" The error is coming from the CameraController script, at the Camera3D's look_at() function. This only seems to happen when moving the camera above the character's head. Any idea how to fix this? I've also tried copy/pasting your code directly and I get the same error. I double checked my node set up as well and everything seems to be the same as yours in the video.
I've also noticed that when lerping the movement, when strafing, it causes the character to move in a forward-diagonal way. I could be mistaken but it looks like the same thing is happening in your video as well near the end. Is this intended? How would one set it up so the player only moves true left or right? Edit: Seems like you address this in your C# video by moving the LookAt node farther from the player.
You may need to adjust the limits of your clamp that error usually means your camera is directly vertical above the player and your cameras direction and up vector can't be the same value.
@@FinePointCGI I don't know what I did, but I re-wrote part of the code and it's working fine now. I have no idea what changed or what I did wrong...oh well!
@@Bora42896 I don't know exactly what I did wrong originally. I just re-wrote the code again and it started working. I'm not sure what the problem was.
Hey I followed this tutorial and everything worked, but when I test it out, my player model mesh rotates while jumping. Sometimes it will even swing around and clip into the floor. I don't want this, how do I fix it?
when I do line 21 and 22 for the camera controller they both get errors saying unexpected identifier In class body I don't know if its the tempRot or something
Why is there a small double jump during the jump before landing? This is also noticeable on the video, but the author did not say a word about it. I think this is a bug, but I don't understand why this is happening.
I call it out in the video or at least I did in the recording. It's due to the idle fall animation I picked. This will not be an issue if the idle fall was designed to work with the land animation.
:33:53: I only added walking and idle animations, but when I tried scripting, the code didn't work. Do you have a solution, or is there a way to add animations directly from the player, similar to 2D? I'm new to 3D and finding it challenging.
Hi, thank you for the tutorial. I'm trying to make your tutorial work in my sample project, and I'm struggling with the rotation feature: model.rotation.y = lerp_angle(model.rotation.y, look_direction.angle(), delta * 12) When I add this specific line of code in it, it only works at first when I use the directional keys to move, but as soon as I let go the model snaps back to the default angle. Not only that, but it doesn't update to the angle it was facing before I let go, so it still feels like it only looks like it's rotating, but doesn't actually stay rotated. can you help me? I know I'm missing something, but I can't tell if it is just the code, the 3d nodes, or a combination of the two. (If it helps this be less confusing, I'm trying to break down the features and isolate just rotating my character as I move it, not rotating the camera with my mouse.)
What a great tutorial thank you! Do we get an "anystate" ability? What if I want to play a death animation from any state but don't want to hook all the connect nodes?
If I want to make the player look at only when I press aim button. and when I don't press the aim button I want the player to rotate toward where ever the player is pressing the keys.. what should I do?
hey tutorial really helped me and also learned a lot and added walking backwards animation to my project, but i tried to add sprinting and did everything right when i press shift to sprint it does sprint and i think walking animation interrupts sprinting animation so i can't really do or know what to do if u got any idea how to fix please reply, thank you.
Does godot offers the alternative to do animations without that horrible UI? I mean being able to code that instead of using the interface to connect them
thx for the tutorial but i have a small issue when ever i jump and walk just as i hit the ground i start walking with landing animation until the landing animation is completed and it goes back to normal ,pls help
this is the code extends CharacterBody3D var sen = 0.5 var current_speed = 9 const walk_speed =6 const JUMP_VELOCITY = 6 const running_speed = 10 @onready var pivot = $cam_origin var is_running : bool = false var is_attacking : bool = false # Get the gravity from the project settings to be synced with RigidBody nodes. var gravity = ProjectSettings.get_setting("physics/3d/default_gravity") func _ready(): Input.mouse_mode = Input.MOUSE_MODE_CAPTURED func _input(event): if event is InputEventMouseMotion: rotate_y(deg_to_rad(-event.relative.x * sen)) pivot.rotate_x(deg_to_rad(-event.relative.y * sen)) pivot.rotation.x = clamp(pivot.rotation.x, deg_to_rad(-90), deg_to_rad(45)) if event.is_action_pressed("sprint"): toggle_sprint() if event.is_action_pressed("attack"): $AnimationTree.set("parameters/conditions/punch", true && is_on_floor()) elif event.is_action_released("attack"): $AnimationTree.set("parameters/conditions/punch", false && is_on_floor())
func _physics_process(delta): # Add the gravity. if not is_on_floor(): velocity.y -= gravity * delta # Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor(): velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration. # As good practice, you should replace UI actions with custom gameplay actions. var input_dir = Input.get_vector("left", "right", "up", "down") var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
# Update animation states $AnimationTree.set("parameters/conditions/idle", input_dir == Vector2.ZERO && is_on_floor()) $AnimationTree.set("parameters/conditions/fall", !is_on_floor()) $AnimationTree.set("parameters/conditions/land", is_on_floor()) $AnimationTree.set("parameters/conditions/walk", input_dir.y == -1 and is_on_floor() and not is_running) $AnimationTree.set("parameters/conditions/back", input_dir.y == 1 and is_on_floor() and not is_running) $AnimationTree.set("parameters/conditions/right", input_dir.x == 1 and is_on_floor() and not is_running) $AnimationTree.set("parameters/conditions/left", input_dir.x == -1 and is_on_floor() and not is_running) $AnimationTree.set("parameters/conditions/run", input_dir != Vector2.ZERO and is_on_floor() and is_running)
move_and_slide() func toggle_sprint(): is_running = not is_running current_speed = running_speed if is_running else walk_speed
My springarm just does not work it is already clipped under the floor when I start and when I tried to move the CameraController node nothing changed and when I changed the position of the springarm it would appear as if the care is right above the players head like a first person and yes the collision masking is properly done but it just won't work
i had a similar issue and it was because i used a different model which had a completely different scale. So I had to change the boundaries of the clamp and also increase the SpringArm length by a lot.
what would I need to change for the character to face the direction he's walking, instead of towards where the mouse is pointing? so instead of strafing right, my character will just face right, and when going backwards, my character will face the camera?
The character I used is owned mixamo you need to go into there character tab in the top right click characters. Underneath there should be a bunch of characters that you can use including the one I used in this video!
@@FinePointCGI i got that sir but the character is not having animation I try to add it but i can't make it properly so please make a new one with any character skin and send it's download link sir please.
at 18:30 for some reason my Godot is saying "Node Not found: "LookAt" (relative to root/Node3D/MeshInstance3D)" i tried to copy everything that you did
@@FinePointCGI thanks for the reply. yes I found that solution later after commenting. What Im currently considering is maybe connecting several blend2ds with the statemachine instead or maybe replace it entirely with BlendTree as it seems to exponentially increase in complexity the more animations you have. it is faster to set up with few animations though.
This tutorial was exactly what I needed to understand how the animation tree conditions worked! It just wasn't clear to me that adding a condition to a transition resulted in a new property on the animation tree node. I really appreciated the starter project so I could get right to the details of the tutorial.
Some critiques on the video
1) You could remove the manual "lookAt" code that makes the camera point at the head of the character if you set the controller (and by extension the spring arm's origin) to the same global position as the "lookAt" node in the controller's code - then the camera will naturally point at the place that you want without making manual adjustments to the camera's rotation
2) the state machine could be drastically simplified if you inserted a 2d blendspace for the walk/strafe animations instead of inserting all of the animations directly, then the walking logic can be handled by a single set of transitions and the animations will blend seamlessly between walk and strafe
Hey thanks for watching also, thank you for the critiques! I actually do number 2 in my root motion tutorial I didnt think about using it until my c# version of this tutorial! As for 1 ill have to look at it.. I think I do something similar to this on my root motion tutorial as well but I don't remember..
Nomination for best upcoming Godot RUclipsr.
Nah heartbeast is way better!
@@FinePointCGI I don't know I have watched him also and yes he is good but I think you have them all beat.
@@FinePointCGI hell naw
Right on time! Started playing around with animations yesterday and this video really helps! I appreciate your hard work!
Hey thanks I hope it out was useful!
Excellent tutorial in third person, very good!. I hope you continue another one: where the character executes actions by touching objects, for example, climbing on a box
About the rotations, in code they're expressed in radians. So @11:44, -1 actually means 60° (PI/3) and is above the character, while 0.25 corresponds to 14° close to the ground.
You should include delta time in lerp statement. If framerate changes the bahavior of rotation will be unexpected.
This makes sense! I have noticed some odditys here and there so that's probably why!
How can I do that?
lol perfect timing!! literally searched for this a half hour after it came out.
I hope you find it useful!
رحم الله والديك حبي والله لو ما انتة چان هسة شامر هالسالفة التعبتني وراية....thanks alot❤️
I'm an absolute beginner so I really appreciate this! I was trying to learn another character controller one and then add my own stuff to it (bc I want to try to do stuff on my own at least for practice in between tutorials? So I'm not just doing tutorials I guess to begin xD but someone was coding the movement manually instead of using state machines and state machines is SO much easier holy heck. The jump and fall was driving me crazy because of an locked/unlocked animation situation. So greatful for this
best explanation for State Machine and Animation Tree so far that i found !
Thank you for this. I painstakingly went through the animations to fix the weird fall landing issue.
Yeah it's a bad animation on my part to use but mixamo animations can be funky
@@FinePointCGI I've only just begun learning Godot and figured it was a chance to learn Godot a bit more.
For all newcomers like me:
40:30 I think a clean solution is a blendspace 2d node for all walking, strafing and idle animations. I use blendspace 1d for my character because I don't need strafing and it works very well. And maybe we can put the jumping/falling stuff in a seperate state machine node, but I didn't try it myself.
Thanks for this tutorial, it helped me a lot!
Just found this channel, and this is amazing timing as I am new to Godot and with the new version out there this is very convenient. Keep it up!
Hey Welcome! I hope I can help you out! Let me know if there's any topics you think would be good to be covered and ill be more then happy to look into it.
if you are having problems with the lerp section, what i did is I changed .05 to 4.2 * delta and also I put the position of the LookAt node in camera controller to -400. I dont know if this is good practice or a good solution but it works much better than before. I also have the y position of the LookAt node in camera controller to 2(around the same height as my characters head)
That does seem like a good solution when i did that i ran into issues with jumping and my character would learp slow although you should multiply by delta which is something i missed
This is just what I wanted. I can't wait to watch this later!
Thank you for sharing your Godot 4 game engine online tutorial it has been a big help for me to get started on my indie Game development journey with Godot 4. Please keep up the good work doing the online tutorial.
I would love if you could do a video of how to set it up the character in blender and if you could add in a way to go from first person to third person view.
really great video though i am learning a lot from your channel so thank you so much.
This was brilliant, thank you!. I finally understand how to use and setup my own state machine controllers!
the lerp lazy rotation part was a life saver
More videos about the Godot engine,it was really useful,I am beginner at this stuff, I wish you luck with your videos
Not sure if you're aware but you can use blend space 2D to make your state machine much much less messy
I do this in my root motion tutorial it's definitely something I learned after the fact!
Use animation tree blender space!!
It would also be good if you make him move crouched. Thanks and great job!
Hi
Thanks for the video
I know this is very basics
I didn't know how to do this 😅
Hey I'm glad it's helping you out!
Instead of running LookAt every frames, it is better to set the spring arm global location to the Node3D target in the Player Scene during _Ready() to get the same result with less runtime calculation
Are you able to describe your learning process, basically how you learned how to make things in Godot? I’m trying to figure out how I should approach things since of course this stuff is very difficult.
My idea as of right now is to continue following tutorials until I have some understanding of what tools I have to use and try to create little mini games with them. I’m not sure how effective this method is, and it’s certainly hard to keep myself motivated with the frustration of not knowing anything.
Either way, I’m curious as to your approach and I would like to see if I could apply your methods to my own.
Tell me when he replies 😅😅
My approach is to just keep trying new things. What really helped was breaking down my problems into smaller sections and then researching those small sections.
Coding things in a very reusable way is something that comes with time so you're going to have hundreds of projects that are not well put together.
Most of my projects today are still not well put together lol
Very good Tutorial. Thank You!
Everything in the tutorial seemed to work great. Up until the lerp section. Not sure if I did something wrong. But now the player only wants to look at center of map. Before adding the lerp code the player followed the camera properly.
jesus that animation state machine is crazy. I could image it being really useful for smaller things but anything with interlinking transitions is just crazy. Would be unmanageable if you added more.
I'm told there is sub statemachines so I'm going to look at them and see if that helps!
@@FinePointCGI ow that would be awesome and make more sense. Great video as always by the way :-)
Wow. That animation tree is a spider-web.
In the c# version I do it quite a bit better using blendtrees but yes in this one it's a web..
Nice video! I personally prefer putting the camera under the player scene using a pivot + spring arm (as you did) and putting the mesh / collisionshape under a node within the player tree so turning the character(mesh/shape) doesn't rotate te camera.
I would love to see you do a tutorial on your view on using concurrent state machines for things like attacking while jumping, running etc!
Oh and a fun thing that instantly adds a little more immersion is to put the LookAt (or the pivot point of the spring arm) a little in front of the character's face! It will give you more feedback when turning your character (A little trick from deconstructing Kingdom Hearts' character controller)
This is amazing tutorial thank you.
You can also use an @export var character : CharacterBody3d in the camera script then just select your character
Awesome tutorial!
Hi mr finepointCGI, can you make tutorial how to create fighting game like Mortal kombat??
Great video! Could you make this kind of 3D tutorials with C# or make a C# version, C# is really better when you make a 3D game on Mobile platform, thanks!
I am currently editing this video for C#. Every video I do I try to do a C# version.
That being said Godot 4 C# does not support mobile yet so id keep that in mind.
This is good stuff. Thanks
@FinePointCGI To avoid the animation spaghetti I added separate straifright and lefts to the idle …. I don’t think the tree stops you from having an animation state more than once, so idle can go to its own set of strain right left falling etc… kind of a mirror of the walk and it’s straif left right and falling. Am I being clear?
great video btw… I am new to Godot and finding your videos have helped me a lot.
Thanks for doing what you do. I really enjoy your videos even though I don't always have time to watch all of them.
I am pretty sure just using a blend tree greatly simplifies the issues you were having with the AnimationTree
Your probably correct however I ran into issues with having it properly transition state. I'm sure I'm missing something but that's why I didn't use it
I can’t really help you there but I know Devmar has done a lot of work with them in Godot 4 and you might be able to glean something from his videos or reaching out to him
You're right it's easier because you can put 5 animations in it (walk at (0, 1) and (0, -1), idle at (0,0), straifleft at (-1,0) and straifright at (1,0)
and set the blend position with input_dir in the script :
$AnimationTree.set("parameters/Walk/blend_position", input_dir)
It definitely is! I'm doing the root motion tutorial right now and I have converted to this method using a state machine and a blend 2D.
Could you do short video how to combine different animation from mixamo into one file using blender.
Sure! I'll make a quick one on that today or tomorrow!
I don't know but I feel like the animation tree state machine is a lot harder to use than the 3.x
It kind of is they want to make more adjustments but it didn't get in on time I'm told..
Has anybody else noticed that when the character strafes he moves forward slightly?
How do I make this work so that my character will strafe perfectly left and right?
Is it a problem with radians vs. degrees?
If i have chosen a mixamo animation that moves the character forward when doing the walking animation how would I prevent that?
this tutorial is amazing and everything works properly besides the animation moving the character away from the camera
Ended up having to go in the animations in blender and setting the Z Location variables to 0,0
when choosing a walk animation in maximo you can tick the box that says "In Place" on their website
I should have looked at your more recent ones first lol...but this seems like a good start and learning (I'm switching from Unity back to Godot). Thank you for this!
@FinePointCGI I still can't get my actual player to turn left/right depending on direction he's moving. I don't know what I'm missing. I copied your code to be sure I didn't have a typo, and I didn't. The mouse rotation does also rotate the player somewhat, but he never "turns" right or left. I don't want to strafe, so I'm not including that part. I have looked and can't find anything on just that one part of "turning with movement direction." I'm sure you're busy but if you could reply with a quick word on how to separate the x to make the player turn right/left I'd be forever grateful.
Notes:
19:43 Alt F4 may not work on Mac dep on settings, so Command-Q will get you out of the game preview. Of course that quits it and you can't just refresh after--have to play from scratch. I think before we set up that feature, we should set up ESC to release mouse control? That was a panic moment being locked in game with no "escape" lol (and don't say use PC lol).
Really had to play with LookAt[Cam] positions (1.5 on Y and -7.5 on Z) and SwingArm (.5 on Y) settings to get Player to not look below floor. The script settings only seemed to limit its view ABOVE the floor, but not below.
Also 'Character character in CameraController Script wouldn't work...had to change Character to CharacterBody3D - CharacterBody3D character (guessing bc the player script says "Extends CharacterBody3D" at the top?).
I asked Chatbot for "In Godot 4.1 3d, my camera looks below the floor. how do I limit its tilt" and it gave me Max and Min PITCH. Thoughts on this option? Seems much simpler to put it halfway up the player then use pitch than all the stuff here.
In 4.1 I cannot change the advance condition...it's showing & sign and won't let me edit it. I can't keep going in your tutorial until I find the cause of that and I cannot even after an hour of searching😕 EDIT: AHAHAAA I had the window squished so I could see RUclips & Godot at the same time...so the actual text window after the & wasn't showing/clickable. WOW. That's an hour of being an idiot I'll never get back lol.
Thank you
how would you do a blendtree of this? i have a first person character controller with some animations mapped to the left and right, as well as forward buttons for view sway and i wanna blend between them as i'm strafing
Все супер, только из-за функции lerp() мой персонаж подергивался во время бега (он иногда поворачивался на 180 градусов вокруг своей оси). Заменил на lerp_angle() и проблема решилась🥳🎉. Спасибо за видео.👍
Thanks for great video.
I tried to add an attack animation, just saw that attack animation always runs , how can I set attack condition to false after attack finished?
I tried animationtree, animation_finished signal, for some reason , animation still fires twice.
Thank you so much for this tutorial. But do you know how to assign button inputs to animations?
I followed the tutorial but I'm not sure how to make my player's animation for attack to play after pressing the "B" button.
i kept getting Parser Error: The identifier "global_position" isn't declared in the current scope. ,
though i thought i followed everything correctly :/
just realized this is for godot 4 not 3 o_o
Will this tutorial have part 2 with more gdscript actions? 🎤
I plan to add vaulting climbing running sneaking and adjusting the character system to only look at a place when you lock on. I may also add dodging as well
@@FinePointCGI It's good that you'll do part 2 with all that you've said. It will be great when it comes out
In GDScript could you explain how to get on a cube or a table by pressing a button?
You mention pretty early into the video how you were able to collapse the animations into just one in blender - do you have more material explaining that a bit more in depth? I am very comfortable in blender, but have done very little with exporting animations out of there.
I take it back - i found it. Youre great.
Hey i love the fact that this actually manages to work as all other one failed to work on mobile, however i noticed that when i jump my character will do this rocking motion. I looked through the code to see if maybe i mess up somewhere but it seems to be right. a small adjustment i made was to move the LookAt node very far but this can make thing harder for levels i fear later down the line as the character still tilts itself in the air. do you know how i can completely lock the axis of the player to prevent this using your camera set up/script?
so if you were to add a punching animation to this it would turn into a cobweb?
Around 21:00 minutes, adding the look_at() function, when moving the camera up it causes the screen to flicker and spams the error:
"Up vector and direction between node origin and target are aligned, look_at() failed"
The error is coming from the CameraController script, at the Camera3D's look_at() function. This only seems to happen when moving the camera above the character's head. Any idea how to fix this?
I've also tried copy/pasting your code directly and I get the same error. I double checked my node set up as well and everything seems to be the same as yours in the video.
I've also noticed that when lerping the movement, when strafing, it causes the character to move in a forward-diagonal way. I could be mistaken but it looks like the same thing is happening in your video as well near the end. Is this intended? How would one set it up so the player only moves true left or right?
Edit: Seems like you address this in your C# video by moving the LookAt node farther from the player.
You may need to adjust the limits of your clamp that error usually means your camera is directly vertical above the player and your cameras direction and up vector can't be the same value.
@@FinePointCGI I don't know what I did, but I re-wrote part of the code and it's working fine now. I have no idea what changed or what I did wrong...oh well!
@@Bora42896 I don't know exactly what I did wrong originally. I just re-wrote the code again and it started working. I'm not sure what the problem was.
I'm having the same problem. Already checked the script and still can't see the problem :(
Hey I followed this tutorial and everything worked, but when I test it out, my player model mesh rotates while jumping. Sometimes it will even swing around and clip into the floor. I don't want this, how do I fix it?
when I do line 21 and 22 for the camera controller they both get errors saying unexpected identifier In class body I don't know if its the tempRot or something
Why is there a small double jump during the jump before landing? This is also noticeable on the video, but the author did not say a word about it. I think this is a bug, but I don't understand why this is happening.
I call it out in the video or at least I did in the recording. It's due to the idle fall animation I picked. This will not be an issue if the idle fall was designed to work with the land animation.
@@FinePointCGI I understand. Thanks!
:33:53: I only added walking and idle animations, but when I tried scripting, the code didn't work. Do you have a solution, or is there a way to add animations directly from the player, similar to 2D? I'm new to 3D and finding it challenging.
My man, the camera is always centered in the character. I'd like to put him little to the left, like Gow or RE4. How cai I do this with your code?
im having some issues with the camera. it seems to start spinning very quickly when i try to move the camera like 180 degrees in game.
Hi, thank you for the tutorial.
I'm trying to make your tutorial work in my sample project, and I'm struggling with the rotation feature:
model.rotation.y = lerp_angle(model.rotation.y, look_direction.angle(), delta * 12)
When I add this specific line of code in it, it only works at first when I use the directional keys to move, but as soon as I let go the model snaps back to the default angle. Not only that, but it doesn't update to the angle it was facing before I let go, so it still feels like it only looks like it's rotating, but doesn't actually stay rotated.
can you help me? I know I'm missing something, but I can't tell if it is just the code, the 3d nodes, or a combination of the two.
(If it helps this be less confusing, I'm trying to break down the features and isolate just rotating my character as I move it, not rotating the camera with my mouse.)
What a great tutorial thank you! Do we get an "anystate" ability? What if I want to play a death animation from any state but don't want to hook all the connect nodes?
the root statemachine could have a death state.
anyone found out a way so those animation statemachines won't get so messy?
If I want to make the player look at only when I press aim button. and when I don't press the aim button I want the player to rotate toward where ever the player is pressing the keys.. what should I do?
niceeee
hey tutorial really helped me and also learned a lot and added walking backwards animation to my project, but i tried to add sprinting and did everything right when i press shift to sprint it does sprint and i think walking animation interrupts sprinting animation so i can't really do or know what to do if u got any idea how to fix please reply, thank you.
@@AstaRoggers So something I cover in the c# version of this is using the blend space 2d and it is a better way to go about this in my humble opinion.
Does godot offers the alternative to do animations without that horrible UI? I mean being able to code that instead of using the interface to connect them
How to import GBL file?
How did you import your character on the node?
If you export your file as a gltf file it will auto import into godot as long as you put it in the project structure
thx for the tutorial but i have a small issue when ever i jump and walk just as i hit the ground i start walking with landing animation until the landing animation is completed and it goes back to normal ,pls help
this is the code
extends CharacterBody3D
var sen = 0.5
var current_speed = 9
const walk_speed =6
const JUMP_VELOCITY = 6
const running_speed = 10
@onready var pivot = $cam_origin
var is_running : bool = false
var is_attacking : bool = false
# Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
func _ready():
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
func _input(event):
if event is InputEventMouseMotion:
rotate_y(deg_to_rad(-event.relative.x * sen))
pivot.rotate_x(deg_to_rad(-event.relative.y * sen))
pivot.rotation.x = clamp(pivot.rotation.x, deg_to_rad(-90), deg_to_rad(45))
if event.is_action_pressed("sprint"):
toggle_sprint()
if event.is_action_pressed("attack"):
$AnimationTree.set("parameters/conditions/punch", true && is_on_floor())
elif event.is_action_released("attack"):
$AnimationTree.set("parameters/conditions/punch", false && is_on_floor())
func _physics_process(delta):
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
# Handle jump.
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = JUMP_VELOCITY
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
var input_dir = Input.get_vector("left", "right", "up", "down")
var direction = (transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if direction :
velocity.x = direction.x * current_speed
velocity.z = direction.z * current_speed
else:
velocity.x = move_toward(velocity.x, 0, current_speed)
velocity.z = move_toward(velocity.z, 0, current_speed)
# Update animation states
$AnimationTree.set("parameters/conditions/idle", input_dir == Vector2.ZERO && is_on_floor())
$AnimationTree.set("parameters/conditions/fall", !is_on_floor())
$AnimationTree.set("parameters/conditions/land", is_on_floor())
$AnimationTree.set("parameters/conditions/walk", input_dir.y == -1 and is_on_floor() and not is_running)
$AnimationTree.set("parameters/conditions/back", input_dir.y == 1 and is_on_floor() and not is_running)
$AnimationTree.set("parameters/conditions/right", input_dir.x == 1 and is_on_floor() and not is_running)
$AnimationTree.set("parameters/conditions/left", input_dir.x == -1 and is_on_floor() and not is_running)
$AnimationTree.set("parameters/conditions/run", input_dir != Vector2.ZERO and is_on_floor() and is_running)
move_and_slide()
func toggle_sprint():
is_running = not is_running
current_speed = running_speed if is_running else walk_speed
My springarm just does not work it is already clipped under the floor when I start and when I tried to move the CameraController node nothing changed and when I changed the position of the springarm it would appear as if the care is right above the players head like a first person and yes the collision masking is properly done but it just won't work
i had a similar issue and it was because i used a different model which had a completely different scale. So I had to change the boundaries of the clamp and also increase the SpringArm length by a lot.
what would I need to change for the character to face the direction he's walking, instead of towards where the mouse is pointing? so instead of strafing right, my character will just face right, and when going backwards, my character will face the camera?
I am going to be updating this tutorial soon to add this I just need to iron out some small stuff
@@FinePointCGI looking forward to it, thanks for your reply!
Perfect but i think the player dont need to go back
Sir please provide the character download link that you used sir please
The character I used is owned mixamo you need to go into there character tab in the top right click characters. Underneath there should be a bunch of characters that you can use including the one I used in this video!
@@FinePointCGI i got that sir but the character is not having animation I try to add it but i can't make it properly so please make a new one with any character skin and send it's download link sir please.
Hi, what program are you using to display keystrokes?
I use a tool called carnac!
@@FinePointCGI thanks
at 18:30 for some reason my Godot is saying "Node Not found: "LookAt" (relative to root/Node3D/MeshInstance3D)" i tried to copy everything that you did
Double check the path to the node it's possible the look at node may be tucked under something else.
@@FinePointCGI tyy it was the path node :D
Bhai please please please please please please pura same yahi chij ki hai lekin joystick kese lau batado please 😢😢😢😢
If you name the animatios to "idle cycle" "walk cycle" and so on...they repeat by default.
this looks so painfully finnicky. is there really no easier way to do this?
I have a follow on that shows a slightly better way to handle the animation transitions using 2d blending
@@FinePointCGI thanks for the reply.
yes I found that solution later after commenting. What Im currently considering is maybe connecting several blend2ds with the statemachine instead or maybe replace it entirely with BlendTree as it seems to exponentially increase in complexity the more animations you have.
it is faster to set up with few animations though.
That's a lot of coding for a simple action!