-
Notifications
You must be signed in to change notification settings - Fork 111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix game crashing when player dies. Instead, game restarts. #101
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,7 +37,8 @@ func _unhandled_input(event): | |
_change_state('attack') | ||
get_tree().set_input_as_handled() | ||
return | ||
current_state.handle_input(event) | ||
if current_state: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This shouldn't be part of the same commit as it's unrelated. Also, I have to check the code but I feel it's not the right fix to keep the code maintainable. There shouldn't be cases where the input gets forwarded to a nonexistent state. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's because the player performed Additionally _unhandled_input is an internal engine method so it can't be avoided without other changes. I would suggest not doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have to get back into the code, the state machine should belong to the player and be freed with it. And yeah it probably shouldn't call queue_free upon dying then. |
||
current_state.handle_input(event) | ||
|
||
func _on_Health_damage_taken(new_health): | ||
_change_state('stagger') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be in the player script. Rather in a file like Game.gd or something similar.