This series is so good from a tutorial standpoint - straight to the point, clear audio, it's clear what you're doing and why and very few bugs in the code. Hoping you continue this, most tutorials don't even cover a combat system
Also, one thing to add, since Godot 4: "cast_to" is now "target_position" (@eaglestdogg mentioned this) And In the if else statement of !ray.is_colliding, around line 73, add a new line that resets the percent_to_next_tile to 0.0, this can fix a bug when walking into a wall and directly turning back
I´ve started with Godot a couple of weeks ago. and this is the best Tutorial i have watched until now. I hope you create more tutorial series maybe with a 3d scene
i turned the trees and flowers into a tilemap too. so the scenetree is much tidyer and not more so long and messy. Trees can use 32x16 Pixel cells and the options Half Offset : Offset X, Tile Origin : Bottom Left and Y Sort : On in the tilemap-properties. Use the whoole graphic as the visible size of the tile and add a 32x32 square collision box aligned to the top. In the tileset-properties under SelectedTile set Tex Offset y : -16 Place this Tilemap in the YSort to make the player appear correctly behind the top of trees and in front of the bottom areas of trees. And set the collision properties of this tilemap the same as at the single tree was. I think, it´s a good idea, if all single-object-scenes (player, buildings, etc) in the YSort have the bottom edge of their contents on the y-origin. For the flowers you can create an animated texture just like used for the water. So you can add them to the tileset of an other 16x16 Pixel tilemap. If you make a tall grass-tilemap as i tell under the video about the tall grass, you can have the flowers in that same tilemap, beyause i coded it to activate it´s effects only on tall grass tiles. Tilemaps also simplify Terrain designing because you can just draw the objects into the 2d-view.
Hey all, for Godot 4 you need to add percent_moved_to_next_tile = 0 to the else branch for your if!ray.is_colliding() check. Otherwise the character takes an extra step when you turn around from a collision.
Late but, I fixed it by adding "percent_moved_to_next_tile = 0.0" in the else part of the raycast check. As in: if !ray.is_colliding(): ... else: percent_moved_to_next_tile = 0.0 is_moving = false Hope that helps, if not you, maybe the future viewers.
Excellent tutorial, but I have a small question. Why don't we use a tileset for the trees? You can do everything you need with a tileset as well--is there something I'm missing, or is it just personal preference?
Great tutorial as usual, thank you! In terms of performances, is it better to handle the trees as tiles rather than collision instances? It's usually a pain to do so since you have to draw the top on a different layer but I'm kinda worried about performances in the long run with that many instances
How does your water collision example work with the prospect of getting Surf? Or, more broadly, what if you want a type of tile to be passable only if a certain condition is met?
Thank you for these great tutorials! Quick question though, for the trees couldn't you just set them as a tilemap and paint them in like you can with grass? Or do you have to duplicate them because of the collision box?
came back to this video to report a potential bug in Godot 4.3. when I got to this part I had to exclude the /2 in the var desired_step: Vector2 = input_direction * TILE_SIZE /2 calc in the move function i forget why but i think it uncentered my player from the tiles when i collided with an object which made it impossible to walk over say a 1x1 grass tile etc could be due to my player being a tad larger than a 16x16 tile but anyway I have a fix. so instead of doing var desired_step: Vector2 = input_direction * TILE_SIZE /2 ray.target_position = desired_step in the move func do ray.rotation_degrees = look_direction look_direction is just declared as var look_direction at the top of the script now in a new func _process(delta: float) -> void: add these if statements if facing_direction == 1: look_direction = -90 if facing_direction == 2: look_direction = -180 if facing_direction == 3: look_direction = 0 if facing_direction == 0: look_direction = 90 I basically printed out the facing direction and then correlated that with the rotation degrees where i wanted to rotate the racast this works the exact same and prevents the player from colliding with a tree and then walking away and being uncentered on the tiles which causes the game to function incorrectly. I also have my raycast target_position set to x: 0 and y: 14 this size firs with my sprite and may be different if your using the assets provided. not sure if this is a 4.3 issue or because my character is too large or what but here's the fix if anyone needs it goodluck!
@@astrophel12 glad this helped I ran into a few more problems along the way, in the future id like to find a more elegant solution to detect when a player is inside an area2D since we have custom collision this makes things a tad complicated. I went beyond this tutorial and implemented a hard coded battle system which will need to be made modular to handle different mons and such this tutorial series to a point is very good until well its not... since its outdated now sadly
Is there much, if any, reason to do the ysort over just painting the trees in the top to bottom order from the start knowing that will occur? Also, what is the reason you make your sprites their own scene instead of just grouping child nodes in the main scene? Is that for reusability across scenes without constantly redeclaring them?
I know i'm kinda late, but I'm following this tutorial, I did as you did, but my flowers are still out of sync when the game plays. Even though I've added the script
That's a good point, if we're not going to have any other functionality for it, it's best to have it as an animated tile. I might make that change in later videos, thanks for pointing it out!
Grrrr I'm so angry. I had a few completed projects from youtube vids that I did last year. I recently had my hdd crash and had to get a new one. 2 completed projects weren't in the Godot folder when i saved on my usb. T.T Still on my broken hdd..which will cost a lot to recover some data from. :((
for anyone watching this now godot 4 changed the property cast_to to target_position so you'll have to change that from the tutorial code
my character stopped moving is there a reason for that?
Absolute hero.
thank you
bro you are a legend! ong
This series is so good from a tutorial standpoint - straight to the point, clear audio, it's clear what you're doing and why and very few bugs in the code. Hoping you continue this, most tutorials don't even cover a combat system
I agree completely!
Also, one thing to add, since Godot 4:
"cast_to" is now "target_position" (@eaglestdogg mentioned this)
And
In the if else statement of !ray.is_colliding, around line 73, add a new line that resets the percent_to_next_tile to 0.0, this can fix a bug when walking into a wall and directly turning back
thank you
You're amazing thanks this works
Love this series! It’s helping me a lot! I hope it continues for as long as possible ! 👍
I´ve started with Godot a couple of weeks ago. and this is the best Tutorial i have watched until now. I hope you create more tutorial series maybe with a 3d scene
i turned the trees and flowers into a tilemap too.
so the scenetree is much tidyer and not more so long and messy.
Trees can use 32x16 Pixel cells and the options Half Offset : Offset X, Tile Origin : Bottom Left and Y Sort : On in the tilemap-properties.
Use the whoole graphic as the visible size of the tile and add a 32x32 square collision box aligned to the top.
In the tileset-properties under SelectedTile set Tex Offset y : -16
Place this Tilemap in the YSort to make the player appear correctly behind the top of trees and in front of the bottom areas of trees.
And set the collision properties of this tilemap the same as at the single tree was.
I think, it´s a good idea, if all single-object-scenes (player, buildings, etc) in the YSort have the bottom edge of their contents on the y-origin.
For the flowers you can create an animated texture just like used for the water.
So you can add them to the tileset of an other 16x16 Pixel tilemap.
If you make a tall grass-tilemap as i tell under the video about the tall grass, you can have the flowers in that same tilemap, beyause i coded it to activate it´s effects only on tall grass tiles.
Tilemaps also simplify Terrain designing because you can just draw the objects into the 2d-view.
Thank you these are very helpful tips!
Hey all, for Godot 4 you need to add percent_moved_to_next_tile = 0 to the else branch for your if!ray.is_colliding() check. Otherwise the character takes an extra step when you turn around from a collision.
I WAS STRUGGLING WITH THIS EXACT THING THANK YOU SO MUCH
ty
Thanks again for the tutorial, really enjoying it, can't wait till the next one.
5:09 Hey dude can you help me out? I moved it under the if statement but occasionally it still stutters
Late but, I fixed it by adding "percent_moved_to_next_tile = 0.0" in the else part of the raycast check.
As in:
if !ray.is_colliding():
...
else:
percent_moved_to_next_tile = 0.0
is_moving = false
Hope that helps, if not you, maybe the future viewers.
@@vaalalves TY! your a legend!
@@vaalalves I know it's almost a year later, but thank you so much for this!!! I was going crazy lol
This guy was so good I wish he would return. Anyone have similar tutorial series to follow?
When drawing tiles, you can do ctrl+shift + left click to draw filled box regions. Switch that to right click and you can erase.
Thanks! Thats really helpful to know
Excellent tutorial, but I have a small question. Why don't we use a tileset for the trees? You can do everything you need with a tileset as well--is there something I'm missing, or is it just personal preference?
Great tutorial as usual, thank you!
In terms of performances, is it better to handle the trees as tiles rather than collision instances? It's usually a pain to do so since you have to draw the top on a different layer but I'm kinda worried about performances in the long run with that many instances
How does your water collision example work with the prospect of getting Surf?
Or, more broadly, what if you want a type of tile to be passable only if a certain condition is met?
Very good series, I think we all appreciate it a lot! 😊
Thank you for these great tutorials!
Quick question though, for the trees couldn't you just set them as a tilemap and paint them in like you can with grass? Or do you have to duplicate them because of the collision box?
came back to this video to report a potential bug in Godot 4.3. when I got to this part I had to exclude the /2 in the var desired_step: Vector2 = input_direction * TILE_SIZE /2 calc in the move function i forget why but i think it uncentered my player from the tiles when i collided with an object which made it impossible to walk over say a 1x1 grass tile etc could be due to my player being a tad larger than a 16x16 tile but anyway I have a fix.
so instead of doing
var desired_step: Vector2 = input_direction * TILE_SIZE /2
ray.target_position = desired_step
in the move func
do ray.rotation_degrees = look_direction
look_direction is just declared as var look_direction at the top of the script
now in a new func _process(delta: float) -> void:
add these if statements
if facing_direction == 1:
look_direction = -90
if facing_direction == 2:
look_direction = -180
if facing_direction == 3:
look_direction = 0
if facing_direction == 0:
look_direction = 90
I basically printed out the facing direction and then correlated that with the rotation degrees where i wanted to rotate the racast this works the exact same and prevents the player from colliding with a tree and then walking away and being uncentered on the tiles which causes the game to function incorrectly. I also have my raycast target_position set to x: 0 and y: 14 this size firs with my sprite and may be different if your using the assets provided.
not sure if this is a 4.3 issue or because my character is too large or what but here's the fix if anyone needs it goodluck!
I'm facing the same problem, your solution is super effective
@@astrophel12 glad this helped I ran into a few more problems along the way, in the future id like to find a more elegant solution to detect when a player is inside an area2D since we have custom collision this makes things a tad complicated. I went beyond this tutorial and implemented a hard coded battle system which will need to be made modular to handle different mons and such this tutorial series to a point is very good until well its not... since its outdated now sadly
Is there much, if any, reason to do the ysort over just painting the trees in the top to bottom order from the start knowing that will occur?
Also, what is the reason you make your sprites their own scene instead of just grouping child nodes in the main scene? Is that for reusability across scenes without constantly redeclaring them?
2:25, what does the $ sign mean here?
I know i'm kinda late, but I'm following this tutorial, I did as you did, but my flowers are still out of sync when the game plays. Even though I've added the script
Thank you so much ❣️
Why not turn the flowers into an animated tile, It'll save on all those scene nodes?
That's a good point, if we're not going to have any other functionality for it, it's best to have it as an animated tile. I might make that change in later videos, thanks for pointing it out!
You can use an extra tilemap for the flowers so their background can stay transparent and you easily can use them on different colored basic terrain.
Pls inventory #9
Grrrr I'm so angry. I had a few completed projects from youtube vids that I did last year. I recently had my hdd crash and had to get a new one. 2 completed projects weren't in the Godot folder when i saved on my usb. T.T Still on my broken hdd..which will cost a lot to recover some data from. :((
Your twitter link in the description is broken
Thanks for letting me know! :)
Great 👍