The question is basically asking if raycasting in a renderstepped loop for a lockon system is good.
I’m making a lock on system which uses the position of the head and the camera’s lookvector, and create a raycast on userinput.
Now, I need it to stop locking on past a distance, my solution for this is in the Renderstepped loop. I cast a ray, again from the head and using the camera’s lookvector. It works great, since the camera already angles itself towards the NPC.
Now, I have tried magnitude. It wasn’t consistent. The ray would hit at 10 studs, but because of the way that magnitude works (takes position from the center of the part, instead of hitting geometry or bounds of part), it doesn’t pass the guard clause in the renderstepped loop, which would check the magnitude.
Raycasting does this perfectly though, since it hits the actual part geometry (to some extent, I think it just hits parts bounds but close enough). I’m not sure if it’s performance intensive though. Help plz.
Will provide script when I get home.