generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Calculating the distance between two bricks?

Previous Thread :: Next Thread 
meSmashsta is not online. meSmashsta
Joined: 31 Jan 2013
Total Posts: 1002
12 Jan 2014 04:52 AM
How do I calculate the distance between Z? I know how to calculate the X and Y but daym idk how to calculate Z...

HOW? For example there are two bricks named p1 and p2, now I want to know the Z difference between those two bricks.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
12 Jan 2014 06:18 AM
a.Z-b.Z
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
12 Jan 2014 06:31 AM
Not sure if trolling or genuine stupidity...
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
12 Jan 2014 07:13 AM
math.abs(a.Z-b.Z)

Where a and b are the position vectors of the parts
Report Abuse
meSmashsta is not online. meSmashsta
Joined: 31 Jan 2013
Total Posts: 1002
12 Jan 2014 07:17 AM
@lamp

yep genuine stupidity, well i was expecting a diff formula for this but... nvm i figured it out, tho thx for the help guys
Report Abuse
lampwnage121 is not online. lampwnage121
Joined: 20 Oct 2012
Total Posts: 4285
12 Jan 2014 07:18 AM
Why would the Z be any different from the X and the Y?
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
12 Jan 2014 07:19 AM
If it involves more than one dimension, then you use Pythagoras, otherwise it's just a simple difference between them.
Report Abuse
meSmashsta is not online. meSmashsta
Joined: 31 Jan 2013
Total Posts: 1002
12 Jan 2014 07:19 AM
thx roflbread! ill keep that in mind!
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
12 Jan 2014 07:23 AM
local A,B = Workspace.PartA.Position,Workspace.PartB.Position
local Distance = Vector3.new(0,0,math.max(A.z,B.z)-math.min(A.z,B.z))
print(Distance.z)

?


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
12 Jan 2014 07:36 AM
@WebGL: y no math.abs?
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
12 Jan 2014 07:38 AM
Questions been answered already
Report Abuse
WebGL3D is online. WebGL3D
Joined: 04 Sep 2013
Total Posts: 28311
12 Jan 2014 07:38 AM
@Not y shud i


~ 1Topcop ~ Java3D ~ WebGL3D ~ Hoard3D ~ Thug3D
Report Abuse
breuning is not online. breuning
Joined: 30 Oct 2008
Total Posts: 4268
12 Jan 2014 08:16 AM
math.sqrt(((p2.x-p1.x)^2)+((p2.y-p1.y)^2)+((p2.z-p1.z)^2))
Report Abuse
breuning is not online. breuning
Joined: 30 Oct 2008
Total Posts: 4268
12 Jan 2014 08:17 AM
or (p2.Position - p1.Position).magnitude
Report Abuse
RoflBread is not online. RoflBread
Joined: 18 Jun 2009
Total Posts: 3803
12 Jan 2014 09:00 AM
The question. Has been. Answered. Already.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image