#Interaction system

1 messages · Page 1 of 1 (latest)

gritty lichen
#

Basically right now i'm just seeing if a prompt is shown. Show the interact ui, if they're holding mouse it interacts. if they stop it doesn't. But i feel like it would just be easier when they start holding mouse to just check around them if an interactable object is near them, instead of doing all the prompt stuff.

#

By just using collectionService and checking the closest one to the player/ if they're close enough to interact

#

Also just renderStepped for the "click to interact" text obviously.

#

I just dont know if its good for preformance

uneven owl
#

ProximityPromptService will always be a better choice, @gritty lichen

#

Roblox already handles proximity, prompting, and interaction logic

#

This is all optimized at the engine level

weak rock
#

jk

gritty lichen
#

what could i do for that using prompts? Cause rn my approach is kinda scuffed. like when the prompt is shown, it goes to a variable like CurrentPrompt, and when they click it just gets like the parent of the currentPrompt and send to server for stuff

uneven owl
#

Be sure to manage event connections

gritty lichen
uneven owl
# gritty lichen event connections?

Assuming you'll bind an event handler each time a prompt is shown, you must unbind the event handler once it is triggered or hidden. This will prevent duplicate event handlers and memory leaks

#

You could also make a lifetime connection and use a guard clause on your currentPrompt upvalue

gritty lichen
#

Thanks for helping