|Topic was automatically imported from the old Question2Answer platform.
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")
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
To do this you will want to make a Global script or “singletons” Singletons (Autoload) — Godot Engine (stable) documentation in English,
you will wanna do this by making a new script and just declaring a variable
var myvar = 100
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
Hexadotz | 2022-08-09 13:36
How about use the
has_method() function on the object that entered the area? For example:
Add a function (e.g.
fling_player()) to the player’s node that would make them move as though they were thrown off a jump pad.