I’m attempting to find the distance between two parts with magnitude. My end goal is to be able to check if the magnitude is greater than a certain number (ie, if partA is less than 50 studs away from partB). But, if I do the math wrong, for example, partA - partB instead of partB - partA or something, will I get a negative number, therefore possible making it like wrong or something
Do I need absolute value? Or will it do nothing? Or, possible hinder it?
BONUS QUESTION
Does constantly checking magnitude essentially create a circle with the radius being the distance you want it to be less than
That makes no sense let me explain
If I wanted to fire something if you were within 50 studs of something, if I constantly checked your magnitude and determined if it was less than 50, does that effectively create an activation zone circle around the part with a radius of 50?
Magnitude is a scalar quantity, it will never be negative. The magnitude of (partA.Position - partB.Position) is equivalent in the reverse. The difference will be the direction since subtracting a vector from a vector results in a vector which has both magnitude and direction.
Regarding checking magnitude frequently, yes but that’s only because your code has instructions to follow telling it not to activate any features if the player is out of range. There’s no automatic creation of an “activation circle” or anything, your code is just written not to do anything to out-of-range players.
I know, I mean if I did write code such as “kill player if their magnitude is less than 50”, would they effectively die when they enter the circle around the part with a 50 stud radius?
local Part = workspace.Part
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(Player)
local DistanceFromPart = Player:GetDistanceFromCharacter(Part.Position)
print("Player"..Player.Name.." is "..math.round(DistanceFromPart).." studs from the part!")
end)
Hopefully this example should assist you in some way.