3543
|
  |
| Joined: 03 Dec 2011 |
| Total Posts: 121 |
|
|
| 25 Mar 2012 11:07 PM |
I've had some experience with CFrame, rotating stuff around a point, etc, but here I've come across a problem.
I'm sending out a laser, having it hit one block, and go out of the other block as if they were connected, like a hole through the world (basically, the Thermal Discouragement Beam from Portal 2).
I have the portal I hit (hit), the CFrame of the point I hit it at (hitp), the second portal in the pair of portals (b)
Portal 0 ------------ hit Portal 1 ------------ b Point on Portal 0 -- hitp
I've done various experiments with it, but I can't find an answer.
TL;DR: I need a way to get the laser from one portal to the other, and get a CFrame from it so I can raycast from that.
My idea:
Get 'offset' of hitp from hit, 'Reverse,' that offset, so It's facing the opposite direction on the opposite side, Turn that to be at the same position on that side, but facing the other way, Rotate that around the center, and put on second portal (b).
There may be a lot better ways of doing this, but I don't know how to manipulate matrices to my needs. I thought this could be done with toObjectSpace and toWorldSpace, but I was mistaken, as these did not ever provide the expected results. toObjectSpace to get the 'offset,' and toWorldSpace to put it back in the world.
I tried separating angles from positions, since angles caused most of the problems, but then if either portal was rotated it wouldn't work correctly, and it never faced the right way.
I'm sure some of you actually understand this stuff, and could provide code, and even better, explain it to me.
(And telling me to go to Wikipedia (to understand matrices) or the RobloxWiki (To understand CFrame) WILL NOT help me at all.)
This is an alternate account. Numbers are awesome. |
|
|
| Report Abuse |
|
|
| 25 Mar 2012 11:24 PM |
Try finding the distance from the origin of the ray to the first part it hit, then subtract that distance from the original range of the ray, then fire it off of the second part. |
|
|
| Report Abuse |
|
Quenty
|
  |
| Joined: 03 Sep 2009 |
| Total Posts: 9316 |
|
|
| 26 Mar 2012 02:24 AM |
You'll have to subtract CFrame relativity away until the laser's position ends up going at a straight line, then readd it back in.
:inverse() shall be your friend. |
|
|
| Report Abuse |
|