Best CPU performance (iterate array of nodes, or detect GO by input collision) detect GO/nodes

Hi, I have a doubt.

I need to detect what object im picking, I have options I think

1 - use nodes, and when player clicks, iterate an array of nodes, checking with gui.pick_node() what node is

2 - use GO, use a go in cursor with a collider, and check which go is touching when the player clicks

what is the best aproach in terms of CPU usage?

thanks

Unless you have a lot of nodes or collision objects it really shouldn’t matter. If you decide to go with iterating a list of nodes you need to be smart about it and try to avoid iterating every frame and only do it on certain events such as action.pressed.

Ok. and if I have hundreds of objects?

You would have to measure this using our profiler.

1 Like

ok thanks