|Topic was automatically imported from the old Question2Answer platform.
I’m trying to make an object that, when touched, will replenish the player’s ability to double jump. My player character is already able to double jump, and a simple boolean value checks if they have already double jumped to stop them from jumping infinitely (which is reset when they touch the ground).
I want my character’s “has_double_jumped” value to become false whenever it touches this object, so that it can double jump once more. After that, I’ll attach a timer to the object so that the player needs to wait a few seconds before it offers an extra double jump.
How can I make it so the object’s script updates a variable stored in the player? I tried defining a function within the player that replenishes the double jump and calling said function on the object’s script:
if body.name == ‘Player’:
but it returns an error: ‘Identifier ‘Player’ not declared in the current scope’
is there any way to make the player or variables inside it global?
Maybe the below will work
if body.name == 'Player':
because your checkign if body is the player, but then you try to use a variable named
Player to enable double jump again, but in this case
body is the player.
You may also be able to do something like
const playerResource = preload("res://path/to/Player.tscn")
if body is playerResource:
so now you can change the player node’s name without worry
godot_dev_ | 2023-06-17 15:21
Got it to work! Thank you for the help!
Nebulabee | 2023-06-17 16:57