Solution for the character not to stand still in Godot Engine 4: Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
I started making a Pokemon-like game in Godot a few months before this series started and I was really stressed out over implementing the movement and map functionality because I wasn't very confident. This came out at the perfect time and I hope you continue with the series. It's a great tutorial.
Thanks for the tutorial, it's exactly the perfect pace for me. I've been looking for more end to end videos that cover the full details of a real project.
Arkeve you are seriously a legend! This is a brilliant tutorial! Very thorough and not skipping over confusing aspects. Thanks so much :) HUUUGELLY Appreciated! This series is fire :D
I think I improved your walking code! One thing that bothers me with a lot of 4D movement is having to only press one direction at a time. If I'm moving down and want to turn left, I have to release down before I can start moving left. In this code, it'll switch to left before you release down (and even revert to moving down if you release left but never released down). It's how pokemon actually works and is a much better feeling and more polished. Here's what I did: First I added this function. It essentially gets a stack of the 4 direction keys in the order they were first pressed... func _process(delta): # Store direction keys in a "stack", ordered by when they're pressed if Input.is_action_just_pressed("ui_right"): direction_keys.push_back("ui_right") elif Input.is_action_just_released("ui_right"): direction_keys.erase("ui_right") if Input.is_action_just_pressed("ui_left"): direction_keys.push_back("ui_left") elif Input.is_action_just_released("ui_left"): direction_keys.erase("ui_left") if Input.is_action_just_pressed("ui_down"): direction_keys.push_back("ui_down") elif Input.is_action_just_released("ui_down"): direction_keys.erase("ui_down") if Input.is_action_just_pressed("ui_up"): direction_keys.push_back("ui_up") elif Input.is_action_just_released("ui_up"): direction_keys.erase("ui_up") if !Input.is_action_pressed("ui_right") and !Input.is_action_pressed("ui_left") and !Input.is_action_pressed("ui_down") and !Input.is_action_pressed("ui_up"): direction_keys.clear() Then, in the function... func process_player_input(): Replace the movement lines you had... if input_direction.y == 0: input_direction.x = int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left")) if input_direction.x == 0: input_direction.y = int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up")) With this... # Get input direction from directional key input stack if direction_keys.back() == null: input_direction = Vector2.ZERO else: var key = direction_keys.back() if Input.is_action_pressed(key): if key == "ui_right": input_direction.x = 1 input_direction.y = 0 elif key == "ui_left": input_direction.x = -1 input_direction.y = 0 elif key == "ui_down": input_direction.x = 0 input_direction.y = 1 elif key == "ui_up": input_direction.x = 0 input_direction.y = -1 else: input_direction = Vector2.ZERO What this does is it checks the "stack" of keys and picks the top one. The reason for this, is so that if you press left while holding down, it'll switch to left (in your code I'd have to release down before being able to turn).
Thank you so much! This works so much smoother, though it is giving me some errors. for the line "if direction_keys.back() == null:" it keeps pumping out the error "back: Can't take value from empty array." several times a second. Any ideas?
@@MrAppleSalad Well that if statement is checking if the array is empty, essentially. Maybe Godot changed something or maybe you or I made an error. Double check you have exactly what I have, and if that doesn't work then use some other way to check if the direction_keys array is empty, like direction_keys.count() == 0 or however gdscript does that (can't remember the syntax off the top of my head).
@@tuckertcs I've definatly got it down the same, and it's not like it crashes or anything it seems to work fine it just gives a bunch of errors. My guess is that you're trying to read the array but instead of it being set to an empty value it's being set to "null", which gives an error as it can't read empty space. Maybe it could be fixed by changing it to some default value? I'm not sure, I'm very novice.
So, to anyone who can have the problem of: The character freeze after a turn, you do nt need to leave the nodes separate, just look at the animation and zoom it until you can place the metod to "finish" the turn right in the momento 0.1. I also did change the walk animations to start in 0.1 until 0.8, the snap was 0.1 but i still used the 0.2 separation for the frames
Nice, Im looking forward to the combat tutorial, since im trying to recreate an Atlantica Online combat system and the turn based part will help me I think :)
There's another godot tutorial guy. I think he was also working on a pokemon style game awhile back. I can't imagine how much time he spent making new monsters.
If you got this error: "Can't travel to 'Idle' if state machine is not playing. Maybe you need to enable Autoplay on Load for one of the nodes in your state machine or call .start() first?" In _ready(), put "animstate.start("Idle")" and in _physics_process(), put "if animstate.is_playing() == false: return" at the top
Solution for the character not to stand still in Godot Engine 4: Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
What's the best way to change the default direction the sprite is facing? We set it to DOWN as default, but when the game starts, the sprite is facing to the left. I popped anim_tree.set("parameters/Idle/blend_position", Vector2(0,1)) in my _ready() function and that seemed to do the trick
I don't know if you still answer, but I have a problem with turning. If I spam 2 directions like left and right or up and down the player gets stuck and I can't move. Any solution? EDIT: I found the solution and it was the animation tree "turn" not being set with the 3 dot thingy instead of the line
Im using godot 4.0 and when i create an animation tree in the AnimationNodeState automatically comes with an Start and End Blendspaces which i cant get rid of.I try to connect the start with the Idle blendspace the program just crash.What to do ?
I was wondering what the license on these sprites are? I modified the player sprite to have a female player option but don't want to accidentally violate someone's license (actually kind of funny that I am using art and don't know who it is so it is someone's art like someone's pc from the original Pokemon games). Anyhow these tutorials are very cool. I am hoping to do more of a puzzler than a monster ranching game in the long run and I am learning allot. Thank you!
I did make these sprites, however they are heavily based on Pokemon and in future videos i might be using copyrighted sprites just to get through the features. So probably not safe to use these sprites in your game for copyright reasons.
If anyone has the same issue, make sure you keep the flipH property on the turn left animation key, and toggle it off that way it overrides the right flipH key
i rewatched the video like 4 times to see where i went wrong, my character doesn't do any of the walk animations when he moves, idk why. ._. EDIT: found te problem, the script is very case sensitive ._. i wrote Walk instead of walk @_@
Solution for the character not to stand still in Godot Engine 4: Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
Solution for the character not to stand still in Godot Engine 4: Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
Thanks for the tutorial! I am using v3.4.4, about 1:20, I see there is another option with defaulted ticked called "Create RESET Track(s)", what does it function? Should I keep it ticked?
Not sure if you have gotten a response yet, but RESET track is an identical track that returns the animation back to the beginning as you move scenes in the editor. For example, if you were editing an animation and left it at .5 second mark instead of 0, then during the game it started from .5 and didnt act how you wanted to test. The reset track automatically puts the animation back to the start etc.
I'm no gamedev, pulled this tutorial up and followed it out of boredom. Somewhere I made an error but its a funny error because I got everything working.. except when my character moves left he stays facing right so I accidentally programmed him to moonwalk. -hee hee intensifies- I don't know if I even want to fix this.
i fixed the thingy but now i can use one key if I want to press any of the right/left/up/down key I cant press another key I just continue with the one i choosed
@@Arkeve It's ok, seems as though I had some kind of conflict in the way I had set things up with the code for the player I wrote while watching your video.
Just so others know, in the first video you called 'func process_player_input' but in this video it is now 'func process_player_movement_input'. Not a big deal whatsoever but it confused me for a second. I can see why you changed the name!
Solution for the character not to stand still in Godot Engine 4:
Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
My god thank you, I had this problem and was confused for how it wasnt working almost went to godot 3 just to make it work.
THANK YOU! I spent 2 hours finding the solution and find this comment
You are the hero the people need
BRO ! I don't know you but I love you ToT
I started making a Pokemon-like game in Godot a few months before this series started and I was really stressed out over implementing the movement and map functionality because I wasn't very confident. This came out at the perfect time and I hope you continue with the series. It's a great tutorial.
Thanks for the tutorial, it's exactly the perfect pace for me. I've been looking for more end to end videos that cover the full details of a real project.
Glad it was helpful!
Arkeve you are seriously a legend! This is a brilliant tutorial! Very thorough and not skipping over confusing aspects. Thanks so much :) HUUUGELLY Appreciated! This series is fire :D
I think I improved your walking code!
One thing that bothers me with a lot of 4D movement is having to only press one direction at a time. If I'm moving down and want to turn left, I have to release down before I can start moving left. In this code, it'll switch to left before you release down (and even revert to moving down if you release left but never released down). It's how pokemon actually works and is a much better feeling and more polished. Here's what I did:
First I added this function. It essentially gets a stack of the 4 direction keys in the order they were first pressed...
func _process(delta):
# Store direction keys in a "stack", ordered by when they're pressed
if Input.is_action_just_pressed("ui_right"):
direction_keys.push_back("ui_right")
elif Input.is_action_just_released("ui_right"):
direction_keys.erase("ui_right")
if Input.is_action_just_pressed("ui_left"):
direction_keys.push_back("ui_left")
elif Input.is_action_just_released("ui_left"):
direction_keys.erase("ui_left")
if Input.is_action_just_pressed("ui_down"):
direction_keys.push_back("ui_down")
elif Input.is_action_just_released("ui_down"):
direction_keys.erase("ui_down")
if Input.is_action_just_pressed("ui_up"):
direction_keys.push_back("ui_up")
elif Input.is_action_just_released("ui_up"):
direction_keys.erase("ui_up")
if !Input.is_action_pressed("ui_right") and !Input.is_action_pressed("ui_left") and !Input.is_action_pressed("ui_down") and !Input.is_action_pressed("ui_up"):
direction_keys.clear()
Then, in the function...
func process_player_input():
Replace the movement lines you had...
if input_direction.y == 0:
input_direction.x = int(Input.is_action_pressed("ui_right")) - int(Input.is_action_pressed("ui_left"))
if input_direction.x == 0:
input_direction.y = int(Input.is_action_pressed("ui_down")) - int(Input.is_action_pressed("ui_up"))
With this...
# Get input direction from directional key input stack
if direction_keys.back() == null:
input_direction = Vector2.ZERO
else:
var key = direction_keys.back()
if Input.is_action_pressed(key):
if key == "ui_right":
input_direction.x = 1
input_direction.y = 0
elif key == "ui_left":
input_direction.x = -1
input_direction.y = 0
elif key == "ui_down":
input_direction.x = 0
input_direction.y = 1
elif key == "ui_up":
input_direction.x = 0
input_direction.y = -1
else:
input_direction = Vector2.ZERO
What this does is it checks the "stack" of keys and picks the top one. The reason for this, is so that if you press left while holding down, it'll switch to left (in your code I'd have to release down before being able to turn).
@The8thZin my bad, add var direction_keys = [] at the top
Thank you so much! This works so much smoother, though it is giving me some errors. for the line "if direction_keys.back() == null:" it keeps pumping out the error "back: Can't take value from empty array." several times a second. Any ideas?
@@MrAppleSalad Well that if statement is checking if the array is empty, essentially. Maybe Godot changed something or maybe you or I made an error. Double check you have exactly what I have, and if that doesn't work then use some other way to check if the direction_keys array is empty, like direction_keys.count() == 0 or however gdscript does that (can't remember the syntax off the top of my head).
@@tuckertcs I've definatly got it down the same, and it's not like it crashes or anything it seems to work fine it just gives a bunch of errors. My guess is that you're trying to read the array but instead of it being set to an empty value it's being set to "null", which gives an error as it can't read empty space. Maybe it could be fixed by changing it to some default value? I'm not sure, I'm very novice.
@@MrAppleSalad That can be fixed by checking "direction_keys.size() == 0" instead of "direction_keys.back() == null" under "process_player_input()"
Thank you, it helped me a lot to learn, for me one of the best programming courses. I am from Argentina.
This tutorial is amazing! Very helpful, thank you for your time on this! :)
Great tutorials! Looking forward to going throught the rest!
So, to anyone who can have the problem of: The character freeze after a turn, you do nt need to leave the nodes separate, just look at the animation and zoom it until you can place the metod to "finish" the turn right in the momento 0.1. I also did change the walk animations to start in 0.1 until 0.8, the snap was 0.1 but i still used the 0.2 separation for the frames
Really good tutorials so far. Thanks!
Nice, Im looking forward to the combat tutorial, since im trying to recreate an Atlantica Online combat system and the turn based part will help me I think :)
There's another godot tutorial guy. I think he was also working on a pokemon style game awhile back. I can't imagine how much time he spent making new monsters.
If you got this error: "Can't travel to 'Idle' if state machine is not playing. Maybe you need to enable Autoplay on Load for one of the nodes in your state machine or call .start() first?"
In _ready(), put "animstate.start("Idle")" and in _physics_process(), put "if animstate.is_playing() == false: return" at the top
Solution for the character not to stand still in Godot Engine 4:
Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
What's the best way to change the default direction the sprite is facing? We set it to DOWN as default, but when the game starts, the sprite is facing to the left. I popped anim_tree.set("parameters/Idle/blend_position", Vector2(0,1)) in my _ready() function and that seemed to do the trick
Yup, thats a good way of doing it!
I don't know if you still answer, but I have a problem with turning. If I spam 2 directions like left and right or up and down the player gets stuck and I can't move. Any solution?
EDIT: I found the solution and it was the animation tree "turn" not being set with the 3 dot thingy instead of the line
Im using godot 4.0 and when i create an animation tree in the AnimationNodeState automatically comes with an Start and End Blendspaces which i cant get rid of.I try to connect the start with the Idle blendspace the program just crash.What to do ?
Did you find a solution? I have the exact same problem
Don't worry about it ,just leave it.
I have the same problem ): please help
I was wondering what the license on these sprites are? I modified the player sprite to have a female player option but don't want to accidentally violate someone's license (actually kind of funny that I am using art and don't know who it is so it is someone's art like someone's pc from the original Pokemon games). Anyhow these tutorials are very cool. I am hoping to do more of a puzzler than a monster ranching game in the long run and I am learning allot. Thank you!
I did make these sprites, however they are heavily based on Pokemon and in future videos i might be using copyrighted sprites just to get through the features. So probably not safe to use these sprites in your game for copyright reasons.
I've got the walking animations working except for the walk left always defaults to the walk right animation. Any idea what could cause this?
If anyone has the same issue, make sure you keep the flipH property on the turn left animation key, and toggle it off that way it overrides the right flipH key
i rewatched the video like 4 times to see where i went wrong, my character doesn't do any of the walk animations when he moves, idk why. ._.
EDIT: found te problem, the script is very case sensitive ._. i wrote Walk instead of walk @_@
I followed the tutorial step by step and i believe the script Is right but the sprite stays still when i move it :/
Could someone help?
Solution for the character not to stand still in Godot Engine 4:
Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
My character moves tile by tile and I'm not sure why. Thanks in advance for any help.
It's not working for me for some reason. The character keeps facing left while walking in any other direction.
Solution for the character not to stand still in Godot Engine 4:
Don't connect the Idle with the Walk, leave everything unconnected, just create the nodes as explained in the video.
Thanks for the tutorial! I am using v3.4.4, about 1:20, I see there is another option with defaulted ticked called "Create RESET Track(s)", what does it function? Should I keep it ticked?
Not sure if you have gotten a response yet, but RESET track is an identical track that returns the animation back to the beginning as you move scenes in the editor. For example, if you were editing an animation and left it at .5 second mark instead of 0, then during the game it started from .5 and didnt act how you wanted to test. The reset track automatically puts the animation back to the start etc.
@@CertifiedGameDev Thank you
Hey I was wondering how would I create 8 directional movement instead? I'm kinda confused about it thenku for the vid btw :0
on line 6, i get the error (6, 1): Unexpected "identifier" in class body. It is written verbatim how you have it.
In Godot 4, you have to use an "@" sign first, so @onready var , I had the same issue, hope this helps.
I'm no gamedev, pulled this tutorial up and followed it out of boredom. Somewhere I made an error but its a funny error because I got everything working.. except when my character moves left he stays facing right so I accidentally programmed him to moonwalk. -hee hee intensifies-
I don't know if I even want to fix this.
my character in all directions
Script Methods don't show up when I Call Method, help please
im 2 years too late but refresh or save your script
great stuff
I can't tell the difference between Turn and Walk , shall we just skip the Turn animation ?
oh I see. In pokemon , we 're able to turn in the same spot
my character freezes in a position but keeps moving forward
solved I only need to activate the animation loop
Bro same problem here with me but it is not solving
@@rokstrogaming7366 in animation player
@@shidflyv2 Thanks bro my problem is solved
well i made it step by step and the player is turning but he's not walking I tried to turn him then press the same key to make him walk it didn't work
i fixed the thingy but now i can use one key if I want to press any of the right/left/up/down key I cant press another key I just continue with the one i choosed
@@eddyrouhana4965 i just completed the first video, and but the character wont move. do you have a fix?
@@CH4YSE i just didnt do the turn just delete all the turn things
@@eddyrouhana4965 thanks for the reply, but I figured it out, I just mispelled a piece of code 😂😂
I fixed the small bug and now he runs way to fast.
If youre using a different sprite you should set the walk_speed to 0.1 to 1.0 you can choose
I am getting "Invalid call. Nonexistent function "travel" in base "Nil" on your line 40
Hmm, I'm not too sure. Would you paste your code so I can see?
@@Arkeve It's ok, seems as though I had some kind of conflict in the way I had set things up with the code for the player I wrote while watching your video.
Just so others know, in the first video you called 'func process_player_input' but in this video it is now 'func process_player_movement_input'. Not a big deal whatsoever but it confused me for a second. I can see why you changed the name!
yesssssssssss
Sad this was the end.
engagement
I always so something wrong god damit xD
First