laser and light bouncing

delorianhayzedelorianhayze Member Posts: 55
edited November -1 in Working with GS (Mac)
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!

Comments

  • Danneman101Danneman101 Member Posts: 59
    I'm not sitting by GS right now, so this is a bit speculative, but try checking out the "Move" method, which specifies a movement at a particular angle relative to the actor.

    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 :)
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    Use three actor prototypes (laser, mirror, beam)

    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!
  • delorianhayzedelorianhayze Member Posts: 55
    Many thanks to you both!
    Awfully kind of ya!
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    You are welcome. Hope it works for ya!
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    Sorry to resurrect an old thread, but I see no reason to open a new one.

    @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
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited July 2013
    @SnapFireStudios -- wow, November, 2011. Have I really been on the forums that long? It seems like just yesterday.....

    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
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    @RThurman - Haha! That moment when you foget the email attachment...
    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
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    edited July 2013
    Ah yes, I see that the other project had the same issue. Any way to fix it?
    - Thomas
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @SnapFireStudios -- Sorry, got a 404 error on the dropbox. Maybe you could just tell me what the fatal flaw is?!?
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    edited July 2013
    Ah well, my dropbox is apparently full.
    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.
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    OK -- now I see. I hadn't noticed that before.

    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?
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    Ok, so the three components are the laser, the beam, and the mirror.

    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
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    edited July 2013
    If neither the laser nor the mirrors move, then the quickest and easiest solution is to place the 'laser beam' actors in their correct locations. You can make the beams visible when the laser fires. (And invisible when the laser is turned off.)
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    If neither the laser nor the mirrors move, then the quickest and easiest solution is to place the 'laser beam' actors in their correct locations. You can make the beams visible when the laser fires. (And invisible when the laser is turned off.)
    Right.. is there a certain mathmatical equation to do that? Something that takes in to account the current angle and new angle I would presume.
    - Thomas
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    When neither the mirrors nor the 'beams' move, the most straight forward equation for placing laser beams between mirrors goes something like this:
    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
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    @RThurman - Alright, thanks for the help. I'm going to assume you meant "X", not "S", and I'll try that out.
    - Thomas
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    You are welcome. (Yes, the "S" was a typo.)

    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?
  • SnapFireStudiosSnapFireStudios Member Posts: 1,603
    Ah sorry, I wasn't thinking correctly when you asked if the mirrors would be rotating. The answer is yes, they will be rotating.
    - Thomas
Sign In or Register to comment.