|
|
|
|
Reply From: |
atorresm |
You are calling get_node
on something that is not a node!
First, instantiate the object:
var camera = load("res://scripts/Camera2D.gd").new()
Then, you can just call the function:
camera.shake()
However, in your case, it seems like you want to do something using a node that is already in the scene that you’re using. In that case, you can just do:
$camera_node.shake()
Assuming camera_node
is your camera with the camera script attached and it is a direct child of the node that owns the script from which you want to do the call.
Hello! I have the same problem, but i need to call a script function attached on spawned enemy.
When i tried to use a load function i got an error message,
I can’t call a dinamic function by that (or something similar)
How i can solve this??
Thank you in advice!
SalvoGalvagno | 2019-04-03 20:59
Hey, thank you for your support so far. This case seems much more complicated than I first thought
So basically I have this structure:
GameManager (scene): contains a player node (Area 2D) + camera + UI and some timers. This scene also has a script that is taking care of player movement + ui + cam movement etc.
Level_1 (scene): contains GameManager + a random level generator which produces a gamefield out of 4 different types of fields (area2D).
And this is the problem I have:
Every time I push a button the player will take 5 steps in a random direction. (this is already managed inside the GameManager.gd). And for each step I want to check (inside the GameManager.gd) on what type of field the character just stepped. Depending on the type of field different events should be triggered.
I hope this helping somehow. Please let me know if you need any more information.
Thx
BigBackPack | 2020-07-29 14:57