Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Syl |
Greets!
Got a cursor_state
variable in the Use button node and its func _on_Use_pressed():
, and i want to get it for a click on the second CollisionShape.
My tree: Imgur: The magic of the Internet
Trouble is, i could get a var at the begining of the Use script, but not the same var inside its function _on_Use_pressed.
So the state of the cursor_state
variable changes after calling _on_Use_pressed()
? Yet you can’t access the variable from inside the function? If the Use
node’s attached script extends the button class, the function can access the variable (maybe by using the self
keyword).
Ertain | 2020-02-20 00:28
Thxs, but the Use node can access the var cursor_state, the CollisionShape cannot, it just get the first var cursor_state, unchanged at the beginning of the script:
extends Button
var cursor = load("res://Textures/Icons/UseC.png")
var cursor_state = "normal"
func _on_Use_pressed():
Input.set_custom_mouse_cursor(cursor)
var self.cursor_state = "selecting"
See? And ‘self’ doesn’t change that.
Syl | 2020-02-20 12:32
Rather than asking how to transfer a variable’s value between 2 seemingly unrelated nodes in your scene tree, maybe you can just explain what you’re actually trying to do here.
It feels like there’s probably something off in your architecture, and rather than providing some contorted, hacky solution to this specific case, maybe you need a different approach.
So, maybe give us a better explanation of what you’re actually trying to do here?
jgodfrey | 2020-02-21 03:28
See my coment to njamster.
Syl | 2020-02-21 12:18