Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: blackant on July 18, 2013, 03:24:13 PM

Title: How to make a Laser Beam ? [SOLVED]
Post by: blackant 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
Title: Re: How to make a Laser Beam ?
Post by: KozTheBoss 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
Title: Re: How to make a Laser Beam ?
Post by: blackant on July 28, 2013, 07:02:18 AM
doesn't work this way...
Title: Re: How to make a Laser Beam ?
Post by: escpodgames 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. :)
Title: Re: How to make a Laser Beam ?
Post by: blackant on July 29, 2013, 10:51:19 AM
finally i get it !

thanks for help !
Title: Re: How to make a Laser Beam ? [SOLVED]
Post by: KozTheBoss on July 30, 2013, 07:12:06 AM
care to share how you solved it? just out of curiousity :)
Title: Re: How to make a Laser Beam ? [SOLVED]
Post by: RowdyMrB 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.