Is there a way to access a collider's script?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Gungniru

I’m trying to change a variable in a script of an object a player is colliding with whenever the player presses space. However, using this method I always get this error whenever space is pressed. Now I understand I have to provide path to the collider’s node, the question is, is there a way around this? I can’t provide a path since I don’t know what I’m colliding with. Surely there is a more sofisticated way than to check for each collider independently.

:bust_in_silhouette: Reply From: kidscancode

get_collider() gives you a node reference in the first place, so you don’t need to use get_node() to find it. Second, you can access a node’s properties directly without the need for get():


This works. Thank you!

Gungniru | 2018-08-21 16:43