Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How to check if an object is near me?

Asked by 8 years ago

I'm well aware of how magnitude works, however I find it's use highly impractical in this case. I have a huge game I'm working on, consisting of many objects. So iterating the entire workspace and everything inside it every fraction of a second or so to check the magnitude between the player and the object, seems excruciatingly memory intensive (not to mention the very noticeable lag that comes with it).


So basically my question is, is there any way to find out if a object is near your character, without constantly iterating the entire world? Maybe Ray Casting is an option? Sorry I don't have any code to provide, I'm just very unsure of how I'd go about this.


Thanks for reading, if you have any insight on how I could go about doing this, I sure would appreciate it!

1 answer

Log in to vote
1
Answered by
ItsMeKlc 235 Moderation Voter
8 years ago

Yes there is ;) Try using Region3, it works similarly to Raycasting! Hope this helped

(http://wiki.roblox.com/index.php?title=API:Class/Workspace/FindPartsInRegion3)

Ad

Answer this question