laser and light bouncing
delorianhayze
Member Posts: 55
Can anyone think of a way of having reflective mirrors and lasers?
Let me explain.
Let's say there's a laser actor in the middle of the stage. And let's say there are four mirrors (each on a different wall of the stage). And let's say the player angles the mirror on the top ceiling wall to face the lower right hand corner. When the laser fires, a red beam would show from the laser to the mirror, to it's bounced lower right hand corner.
To make it harder, the player can move the mirrors wherever they want, causing the red laser to refract and bounce the laser light to its appropriate direction.
Any thoughts?
Many thanks as always!
Let me explain.
Let's say there's a laser actor in the middle of the stage. And let's say there are four mirrors (each on a different wall of the stage). And let's say the player angles the mirror on the top ceiling wall to face the lower right hand corner. When the laser fires, a red beam would show from the laser to the mirror, to it's bounced lower right hand corner.
To make it harder, the player can move the mirrors wherever they want, causing the red laser to refract and bounce the laser light to its appropriate direction.
Any thoughts?
Many thanks as always!
Comments
When hitting the wall, change this "Move" method's angle to the current angle of the light adjusted for the angle of the wall. I'll leave you with the math, but it should be pretty straight forward
Uncheck mirror moveable
Change the beam actor's width to 75, height to 10
Place four mirrors and one laser in the scene. Position the laser at an angle.
In the laser prototype:
--when mouse is down
---- spawn a beam actor
------every .1 seconds:
------direction = self.Rotation, relative to scene
In the beam prototype:
--Change Velocity: speed = 500 (or whatever)
--Collide with actor of type mirror
--Constrain Attribute: self.Rotation To: vectorToAngle( self.Motion.Linear Velocity.X , self.Motion.Linear Velocity.Y )
That's about it!
Awfully kind of ya!
@RThurman - What you said does work fairly well, but there is one fatal flaw. You'll be able to see once you check out the project what the issue is.
Any chance you can think of a way to easily fix this? Only thing I can think of is really short lazer beams with spaces inbetween, or fake mirrors with real ones behind them, neither of which are optimal.
Thanks for any help,
- THomas
I am not sure what the 'fatal flaw' is. There were probably other things that need to be taken into account to get things perfect. It was just a starter idea.
Here is an old example of lasers and mirrors I posted for some other thread. Does it have the same fatal flaw?
http://www.mediafire.com/download/tpa9x072iti7o93/laserAndMirrors.zip
Here is the file: https://dl.dropboxusercontent.com/u/7664602/Pyto.gameproj.zip
You should see the issue when previewing. Ignore the second scene.
- Thomas
- Thomas
Anyway, the issue is, just as in the other project, the beams do not fluidly turn. They touch the edge of the mirror, then stop and rotate, speed away before the center of the object reaches the mirror.
Is there any way around this other than having a fake mirror actor and then the real one invisible behind it? Even that would not work at some angles.
- Thomas
Edit: @RThurman - Download also works now.
Yes, I think you are right. If you want to treat a laser beam as a series of photons, you will need to have short (almost round) actors. It seems to be the length of the photon that is the problem.
Do you actually need the 'beam' to shoot (like a series of bullets). Or can it be a series of "beams" that are static. Does the gun or the mirrors move?
No, the mirror won't need to move, but I'll need to have multiple on the screen in different levels all at different angles. I believe the angles will be 22.5 degrees (45/2), meaning they will either be vertical, horizontal, diagonal, or in between (hopefully you get my point).
I would like to have a solid laser beam if possible, but I can make do with a series of short rapid bursts, although they still need to be longer than they are wide. The nearest size where it starts to look alright is 2x8, which is really too small.
Any other ways to do it that you can think of?
- Thomas
- Thomas
beam.X = (mirror1.S-mirror2.X)/2
beam.Y = (mirror1.Y-mirror2.Y)/2
beam.Rotation = vectorToAngle(mirror1.S-mirror2.X,mirror1.Y-mirror2.Y)
But the most efficient placement equation is called:
TLAR*
*That Looks About Right
- Thomas
But I really don't understand why you don't just place them in their proper locations and turn them on when needed. They are all static, and don't actually move, right? They are just like neon lights that can be turned on and off, right?
- Thomas