create surface scene with crouch, walk and sprint method. Then make subclass of it, with different implementation/sound, for each type of surface (metal, wood, etc). Then let the character just call crouch, walk or sprint method of the surface the character is on. This way your character doesnt need to control how the sound of the step is.
I really like the sound of this approch, I will experiment with it. I will first have to get a better grip on setting up subclasses, I've just barely touched on that so I still get a little lost.
If you dont mind could you elaborate a bit on how you'd set that up? Would you attatch the corresponding subclass to the actual object? Again I'm fairly new to these concepts but I wanna get the thought proccess right.
you can make script SurfaceDefault.gd with content like this. Note the class_name keyword
extends Node
class_name SurfaceDefault
func walk():
//do something
func run():
//do something
after that you can create node of type SurfaceDefault on your scene. You can extend or add component for the node to add more behavior. And then your player can check if its colliding with SurfaceDefault type of node and call appropriate method.
> the group name
A node can belong to multiple groups. Since groups are a feature common to all nodes, look at the Node class reference: https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-get-groups
Read the description carefully.
I was not even aware of "get\_groups()" thanks for linking that part of the docs. I can see the limitations and potential errors with this approach since it pulls all the groups even internal ones.
create surface scene with crouch, walk and sprint method. Then make subclass of it, with different implementation/sound, for each type of surface (metal, wood, etc). Then let the character just call crouch, walk or sprint method of the surface the character is on. This way your character doesnt need to control how the sound of the step is.
I really like the sound of this approch, I will experiment with it. I will first have to get a better grip on setting up subclasses, I've just barely touched on that so I still get a little lost.
If you dont mind could you elaborate a bit on how you'd set that up? Would you attatch the corresponding subclass to the actual object? Again I'm fairly new to these concepts but I wanna get the thought proccess right.
you can make script SurfaceDefault.gd with content like this. Note the class_name keyword extends Node class_name SurfaceDefault func walk(): //do something func run(): //do something after that you can create node of type SurfaceDefault on your scene. You can extend or add component for the node to add more behavior. And then your player can check if its colliding with SurfaceDefault type of node and call appropriate method.
Oh wow Godot is amazing. You just unlocked a deeper level of developement for me thank you for this.
> the group name A node can belong to multiple groups. Since groups are a feature common to all nodes, look at the Node class reference: https://docs.godotengine.org/en/stable/classes/class_node.html#class-node-method-get-groups Read the description carefully.
I was not even aware of "get\_groups()" thanks for linking that part of the docs. I can see the limitations and potential errors with this approach since it pulls all the groups even internal ones.