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
|
  |
| 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 |
|
|
|
| 02 Jun 2013 11:31 AM |
Hard Math Question: 2 + 2 = ??? |
|
|
| Report Abuse |
|
|
Zomebody
|
  |
| Joined: 01 Jun 2010 |
| Total Posts: 789 |
|
|
| 02 Jun 2013 11:33 AM |
@BlueBlood12,
Please stick to my question.... |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| 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 |
|
|