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

Would you use magnitude to detect the nearest HumanoidRootPart?

Asked by 6 years ago

I've never really used magnitude so I'm not sure how it works with Position.

0
Position is a Vector3 x,y,z values magnitude = math.sqrt(x^2 + y^2 + z^2) this is the distance from 0,0,0 => the vector point User#5423 17 — 6y
0
Thanks, this really helps bring light to what I'm thinking of. Revisedy 23 — 6y

1 answer

Log in to vote
0
Answered by
Fifkee 2017 Community Moderator Moderation Voter
6 years ago

Mhm! Good thinking.


The magnitude property of a Vector3 value allows you to determine the distance between two points. I'd do this by iterating over transparent objects named "HumanoidRootPart" that are in a range. It's not really efficient, so I encourage you to come up with a more efficient function that gets the job done.

Example of magnitude:

(rootPart1.Position - rootPart2.Position).magnitude

Happy coding!

0
Ok, It makes alot more sense now, thank you for the insight, this was really helpful! Revisedy 23 — 6y
Ad

Answer this question