Topic was automatically imported from the old Question2Answer platform.
Asked By
Hexadotz
How can i make a scene find a node even if its in another place
Im making a jump-pad that launches the player as soon as they enter its area the thing is idk how to alter the player velocity since its in another scene
Here’s how my code for the jump pad looks like this:
Onready var Player = get_tree.get_root().find_node("Player")
func _on_throw_body_entered(body):
if body.is_in_group("Player"):
Player.Velocity.y = 100
Player.jumppadding = true
Again this is the script for an independent scene which is the jump pad i want it to find the player and change its velocity once they enter the area
and in project settings under AutoLoad adding that script with a node name,
once you do this you can go to any script in any file and instance that var by doing this
MyGlobalScriptName.myvar = 200
doing this will be used a lot down the line from making hp bars to store things in files
Hope this helped! if you have any question on how to do just ask and Ill do my best to answer!
Thank you but i already found a much simpler solution
So when the player enter the area it checks if they’re in that group if so simply this line works
Body.velocity.y = 75
Its really simpler than i thought i also already have couple of singletons for that specific reason but they aren’t that helpful besides marking events or saving stuff