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
 

Laser Rotation/Position Through Portals

Previous Thread :: Next Thread 
3543 is not online. 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
ServerLabs is not online. ServerLabs
Joined: 29 Dec 2010
Total Posts: 2263
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 is not online. 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
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