I’m not sure what the best way to go about making an interactive UI for seating a character would go. I’ve thought of comparing distances of Seats, and what I’ve tried recently is checking touched objects with a sphere around the player (video below).
Would the method I’ve shown above be the best way to go about this? If not, what are some other ideas? I’m not sure if checking touched objects would be performant at all.
You could use Region3 or something similar to get all the parts around the player, then loop through them and put the context action button on the closest object that can be interacted with.
Alright, sounds good. Mainly asked because there’s a ton of cool new stuff being added to Roblox and I wasn’t sure if there was something new that could do this (and well).
Looping through all intractable object will be a lot more performative. Touched events will break down with lots of lag as soon as players start moving around a lot more complex maps. If you start having so many objects that it starts effecting performance you can look into spacial partitioning.
Since you are looking into using different/useful things inside of Roblox, I suggest looking into how you could use CollectionsService to tag seats and make your code a lot simpler.
…Are you absolutely sure using a simple Touched event with a short if statement would be less performant than looping every interact-ableobject? I’m unable to test at the moment.