Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

do i need a detecting system to start measuring distance, or is it not computing heavy?

Asked by 3 days ago

well basically i want to measure the distance between a player and an object, and i know how to do it using the "Player:DistanceFromCharacter", but i dont want it to keep checking that all the time, im afraid it going to create a heavy load, so i was wondering whether or not should i use a hit detection system to start measuring distance or is it unnecessary.

0
I believe it is sort of unnecessary. You can use magnitude. Dovydas1118 972 — 3d

1 answer

Log in to vote
0
Answered by 3 days ago

It is perfectly fine to do this kind of operation every frame. Using Magnitude for example is actually light for you because Vectors already have the Magnitude property. It is no different from reading a property every frame. So just stick with Magnitude instead of a function.

In any case, you only worry when you have to detect between a player and many objects, because looking for 100 objects for example is intensive compared to just one object. In this case, there are multiple ways to handle this. Don't worry about this until you actually notice lag from checking objects constantly.

Examples to solve that are Region3 usage (might be expensive to use though), Quadtrees/Octrees algorithm, Chunk/area location (find where player is and find objects attached to that chunk/area).

Ad

Answer this question