playMaker

Author Topic: How to make a Laser Beam ? [SOLVED]  (Read 5080 times)

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
How to make a Laser Beam ? [SOLVED]
« on: July 18, 2013, 03:24:13 PM »
i started using particles system, but it seems to not be the right way

i would like to set a laser by holding a key , then if it collide something, it should stop here and make FX.

i think something like a box that can be resized to the target.

it looks a little bit complicated
« Last Edit: July 29, 2013, 10:53:58 AM by blackant »

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: How to make a Laser Beam ?
« Reply #1 on: July 18, 2013, 03:49:38 PM »
You could do a raycast from the beam start and forward - when the raycast hits an object, save that as a variable and calculate the distance between it and the player, and then determine the beams length from the distance between the player and the object the beam "hits"

Just off the top of my head, dunno if this would work - worth a shot though
Remember, you don't fail unless you give up trying to succeed!

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: How to make a Laser Beam ?
« Reply #2 on: July 28, 2013, 07:02:18 AM »
doesn't work this way...

escpodgames

  • Hero Member
  • *****
  • Posts: 687
    • Assets
Re: How to make a Laser Beam ?
« Reply #3 on: July 28, 2013, 07:44:27 AM »
Why not? I've done this and it works.

Explain how you went about creating the above example and we can help you make it work. :)

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
Re: How to make a Laser Beam ?
« Reply #4 on: July 29, 2013, 10:51:19 AM »
finally i get it !

thanks for help !

KozTheBoss

  • Full Member
  • ***
  • Posts: 150
  • You dont fail unless you give up trying to succeed
    • Pixel Life - portfolio
Re: How to make a Laser Beam ? [SOLVED]
« Reply #5 on: July 30, 2013, 07:12:06 AM »
care to share how you solved it? just out of curiousity :)
Remember, you don't fail unless you give up trying to succeed!

RowdyMrB

  • Playmaker Newbie
  • *
  • Posts: 6
Re: How to make a Laser Beam ? [SOLVED]
« Reply #6 on: August 07, 2013, 10:37:10 PM »
I just recently solved this for a project I am working on as well.  This is what I do:
- Create a laser beam object prefab made up of a Trail Renderer and Rigidbody and add the attached action that I created.
- I use pool manager to preload the prefabs
- I use ArrayMaker to setup an array of Lasers on a spaceship (I have one that has 8 lasers)
- The prefab laser beams are parented to the lasers when spawned by Pool Manager
- Raycast from Game Object together with Raycast Hit Info actions are used to do a forward raycast and determine Hit/No Hit.  If hit I despawn the the laser beam prefab and kick off an explosion effect which is spawned with Pool Manager as well
- If no hit the laser beam prefab is despawned after a period of time.

That is about it.