- Edited
Currently I am using an if statement but I will have many more if statements by the time I'm through with the project. I was hoping to swap over to a match statement that should be able to process faster than an if statement. These are custom classes. Here is my current code:
var detected = interact_ray.get_collider()
if detected is Sign:
handle_chat_box(detected)
elif detected is Rocks:
handle_ore_interact(detected)
elif detected is Chopable:
handle_tree_interact(detected)
pass
else:
interact_ray.get_collider().player_interact()
Is there a way to put this in a match statement?
This doesn't work because I'm passing in the object and not the objects class, where above I'm using the "is" statement to check the custom class of the object.
var detected = interact_ray.get_collider()
match detected:
Sign:
print("Sign")
Rocks:
print("Rocks")
Chopable:
print("Trees")