Hey everyone!
I’m currently working on a side project and had a quick question about what the most efficient way (in terms of performance) to set up an interaction system is.
In the past I’ve used a lot of different collision objects. The one in the player looks for ones in the interactable object. The player checks every interactable object in range and determines which is the closest.
This approach has worked for several games I’ve made including most recently Second Son: Second Son [Project 2021-8] by IanGoGo
I have been trying to think of a better way to do it. I have come up with another way where I can have one script (a singleton) track all interactable objects in a level and determine the closest one to the player and if it’s in range. This is what I want to try in my test project.
My question is which would be more efficient in terms of performance. Is it better to have tons of different collision objects and only calculate if the player is within them or have the game loop through every object every frame (could also do on a timer and check a few times a second) to determine what the player is closest to.
Thanks!