Like I wanted to use raycasting to make some type of 180º proximity sensor but it was so hard to do. Like the raycast didn’t even detect the parts it needed to detect.
I already deleted the script but like it was also really innefficient.
What should I do instead if I want to make some type of radar or proximity sensor?
Well, if you aren’t concerned with it being a radius, then you could always make a region3 in front of the sensor extending out a certain range in front of it. Otherwise, your best option might just be spawning rays 180 degrees around the front of the sensor like you were trying to do.
Someone told me that’s highly inefficient and it’ll cause so much lag cause too many touch events will be firing. You gotta understand that another car in my game has like 88 baseparts in the model itself.
As far as I know, that is the only way to achieve this. I will definitely try figuring out a more efficient way.
Have you tried that method though?
If you haven’t, there’s no harm in trying.
You know the positions for the player and the detector. At the moment, I’m not too sure how to fully implement the picture. It’s been a while but it does use trigonometry. Hopefully this helps a bit, maybe someone can add to this.
In my game proximity triggers work by having a position as the center, and a part to listen for. It then takes the (PartPositionVector - CenterPositionVector).magnitude to determine the distance the part is. After that, it will just determine whether they’re within reasonable range (20 studs for instance). I think this is more effective than raycasting, if you are trying to do what I think you are trying to do. Rays would probably be more appropriate if you needed to determine the direction the player was coming from or something.
If you want a scan-like action like real life radars do, use a hingeconstraint and a script to make the part oscillate left to right. (Suggestion) in a limit, for example -45 to 45 degrees