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
 

Hard math question.

Previous Thread :: Next Thread 
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
02 Jun 2013 11:06 AM
I will try to explain my question as clearly as possible.

So let's say we have a brick with the following properties:

brick.Size = Vector3.new(200, 1, 1)
brick.Anchored = true
brick.CFrame = CFrame.new(2, 5, -3)*CFrame.Angles(math.pi/16, math.pi/4, -math.pi/8)
brick.Parent = game.workspace

Also, it has some other properties, but those aren't necessary for my question.
We also have a 2nd brick, with most properties the same (including the size). The only difference though, is that the 2nd brick has another position:

Pos = Vector3.new(-4, 7, 6)

Now my question is: What rotation do I have to give to the 2nd brick in order to make it intersect with the first brick and have the point of intersection (the position where both bricks collide) be as closely possible to the middle of the 2nd brick (the position above)?

If someone answers, I would also love an explanation on how you got that answer, so I can use it again with other positions and rotations.
Report Abuse
Zulsoras is not online. Zulsoras
Joined: 10 Sep 2008
Total Posts: 963
02 Jun 2013 11:25 AM
Might want to try with a smaller brick first.

Bump
Report Abuse
BlueBlood12 is not online. BlueBlood12
Joined: 07 Jul 2011
Total Posts: 1377
02 Jun 2013 11:31 AM
Hard Math Question:
2 + 2 = ???
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
02 Jun 2013 11:33 AM
@BlueBlood12,

Please stick to my question....
Report Abuse
Frostglacier is not online. Frostglacier
Joined: 28 Oct 2010
Total Posts: 4177
02 Jun 2013 11:51 AM
Find the angle at which you want it to turn and add a variable to it;

eg. a = math.pi/16 + 1

function here
bla = Vector3.new(1,a,1)
a = a + 1
end



Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
02 Jun 2013 12:06 PM
Point the second brick at the first brick's center by using CFrame.new

Part2.CFrame = CFrame.new(Part2.Position,Part1.Position)
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
02 Jun 2013 12:35 PM
I don't want it to point at the center, but at the nearest point the 2nd brick can collide with the first one :S
Report Abuse
killjoy37 is not online. killjoy37
Joined: 27 Aug 2008
Total Posts: 2821
02 Jun 2013 01:10 PM
Well, you can use raycasting. Treat the first brick as a ray, then use ray:ClosestPoint(Part1.Position) to find your intersecting point, then you can point the second part at THAT position. To treat the first part as a ray, do
ray = Ray.new(Part1.Position,Part1.CFrame.lookVector)
Part2.CFrame = CFrame.new(Part2.Position, ray:ClosestPoint(Part2.Position))
Report Abuse
Zomebody is not online. Zomebody
Joined: 01 Jun 2010
Total Posts: 789
02 Jun 2013 01:44 PM
I didn't know that that even existed. Thanks for the help! I will try using raycasting now.
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