![]() ![]() Similarly with your situation, we'd apply the same logic. If Distance > Range then - If Distance is larger than the "Range" constant, then it will print "Out of range"Įlse - But if it's not out of range, than it's obviously in range, so let's print "In range" Local Distance = (Vector1-Vector2).Magnitude - The distance Here's how we could check the distance: local Vector1 = Vector3.new(0,50,45) The code above will display the distance between these two 3D coordinates, which we can utilize in your situation to create a logic gate using an if statement. ![]() It's very important you enclose this vector operation in parenthesis, since the order of operations still applies, and we don't want to subtract Vector1 by Vector2.Magnitude. For example: local Vector1 = Vector3.new(0,50,45) Magnitude can give you the distance between two objects by subtracting their positions, and using this magnitude operation on the result. There's a special operation you can preform on each Vector3 value, which is called " magnitude" (or, " Magnitude").
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |