Max Raycast count per sec. before things get laggy?

So I was just thinking (and maybe creating something with raycasts) What is the max amount of Raycasts per second (alone) before it gets laggy?

I once created something and it worked fine with 1000 raycasts per heartbeat

I was just curious so I could plan for the future.

Wouldn’t this be in #help-and-feedback:scripting-support ?

I believe it depends how good your computer is. Because it is kinda similar to loops; the faster it is, the more the computer needs to handle it.

I think it is the same with raycasting, not entirely sure though.

I would agree, I was just wondering because once upon a time (about a yea ago) I created this thing where if through a raycast the NPC can see your head, then it will chase you. I was always like ‘raycasts are so expensive: maybe not too much raycasts’

You could use runservice to get the perfect amount of speed to raycast for someones device, as it fires every frame of the players device. This however needs to be done in a local script.

Raycast doesn’t really affect performance much, sure maybe it affects it by a REALLY REALLY tiny amount. So tiny that you can probably have 10000 Raycasts per 1/10th of a Second and be fine.

What really matters is how you’re using the Loop. If a loop is REALLY REALLY fast then it’ll noticably affect the Performance. Pretty sure everyone knows this.

So, you can have as much Raycasts as you want and you’ll be fine. It’s just that you need to use the Loops in a optimized way.

A good example for this is FPS Games, A LOT of Roblox games that includes guns like Criminality, or ANY games that uses Open-Source Gun Engine like FE Gun Kit and ACS… handles their Bullet Hit using Raycast (usually per RenderStepped or Heartbeat). And you can see that The Games doesn’t lag at all, even though there’s probably HUNDREDS of bullets being spawned Per Second. Which if you think about it, that is A LOT of Raycasts and yet… they don’t lag that much.

Doing a LOT of raycast calculation instantly will cause a lot of lag depending on the computer specs. But splitting each workload separately will help a lot to reduce lag

10000 raycasts per 1/10th of a second will lag alot.