Reputation: 1
So I have a game I'm making and I'm making a dash mechanic. I have a player class that the player nodes (that are character2D nodes) inherit from. I (mostly) made it so the player needs to have a dash bar filled up so they can dash. I need to have a signal that resets the players dash meter, and it will connect, but it won't run the function. (I'm using Godot 4.0)
Character2D Script
func _ready():
player.remove_dash.connect(_remove_all_dash)
print("is connected: " + str(player.remove_dash.is_connected(_remove_all_dash)))
func _remove_all_dash():
dash_power = 0
print("function ran")
Player class script
func check_for_dash_input(delta, player_resource: Resource, dash_timer: Timer, input: String, dash_power: int):
dash(delta, player_resource, dash_timer, dash_power)
if Input.is_action_just_pressed(input):
dash_timer.start()
emit_signal("remove_dash")
print("signal emit")
Debug console: is connected: true; signal emit
I tried looking a the docs for Godot 4.0, but that didn't really help.
Upvotes: 0
Views: 117
Reputation: 1
Ok, so it turned out I had to actually set the Player Class in the editor because when I make a Character2D and connect signal, it didn't work.
[how to set player class in the editor][1] [1]: https://i.sstatic.net/W77Iv.png
Upvotes: 0
Reputation: 56
I think signals are really complicated to debug without having the actual project on hand.... but maybe it has something to do with the inheratance?
I guess you could also set a dash_power to 0 in the Player class instead of the Character2D and instead in the Character2D use the dashpower value from Player?
Upvotes: 0