Whats the best way to detect an object

so i have a miner game and i want the blocks to break if the player is at the same location (that produces no lag), as of right now its is using proximity (lag) and i tried to use math to make a proximity (even more lag) the last thing is rays but they too are lag (4 per block) i need a solution

Game: https://flowlab.io/game/play/1560674

You could try using raycast or collision depending on how far away the object is. By Best bet would be raycast since it doesn’t lag at all.
Then again proximity doesn’t lag for me either so idk if you have a poor device (not assuming, just a possible issue), there’s something else causing the lag, or it could be the browser you’re using.

Raycasts definitely lag. They really made my game slow down. I would say have the blocks use a ray cast only when neccessary. So maybe there’s a way for the blocks to use the ray only when the player is close without it causing a lot of lag.

1 Like

Oh, usually it doesn’t lag for me, but then again I only used like one or two raycast so it never really brings too much lag, but I can see where a bunch could.

grazer posted this

1 Like

rays and proximity are the worst

Raycasts and Proximity are pretty good for what you need to do, Grazer just posted that cause it will be the most common issues for lag and to make an example.

Usually this is because Proximities and Racasts set to 100 or 1000 are able to scan all objects within that range every frame. But doing such a large scan eats up CPU and RAM and creates lag for games. But most commonly using raycasts and proximity (on a single object, not clones) have almost no issues when used for a game, just dont try to scan the entire game for every single frame or use too many clones with these and using an always.

3 Likes

Hey @cailem - @JR01 is correct. There is nothing inherently wrong with Raycasts or Proximity checks. If I understand your use correctly (maybe I don’t) then I think you only need to run the check once for what you need. This should be absolutely no problem at all, and you can use a Once block, or Timer or whatever to trigger the check using the new Proximity block from the component section.

Pog when did u add/change it? thank you for adding that change it just made the game playable
(also plz add a max input for the bar block)
thats the last thing i need