Laser Bolt suggestion?

0 favourites
From the Asset Store
A sound pack containing 132 laser gun sound effects, including mono and stereo versions of audio files.
  • Hi all,

    I'm making a space shooter and I'm wondering if anyone has any ideas about creating a laser beam, not a continuous beam, but more like a very long laser bolt. As the bolt hits an object, the object would absorb the energy bolt. You'd see the bolt disappear behind it (absorbing its damage) if it were a line moving off screen.

    I was thinking to maybe expand the width of the sprite as it leaves the player's weapon. Then on collision, to start shrinking the width, but it's not really working.

    I'll post a capx soon, just looking for ideas...


  • You could use an instance variable for the lasers and tie that to the beam's width. Have an event check that variable and adjust the width accordingly.

    Or use opacity: as the laser is absorbed, have it fade out until it's 0 and then destroy it.

  • right.. so the targets are moving.. and if the beam is say 100 in length.. it can hit a target and start to shrink the width of the beam (as if absorbing it) but then if the target moves the new beam length would continue in a straigt path off screen to be destroyed..

    cool thanks.. testing that out.

  • jobel

    The collision with a target could trigger a timer for the laser, something that starts that shrinking process, and stop it if there's no collision.

    I'll be curious to see how it turns out... keep us posted, will ya? ;)

  • yes I'll post the capx here..


  • jobel,

    Is this the sort of effect you're after? capx

    There are a couple of different methods in there - I think option 2 is the best, but option 1 might work for you as well. (Made with R151)

    This was a good distraction from finishing my project....

  • Colludium that is fricken awesome!

    I was not expecting something that looked so cool. I am going to have a look how you did that.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Nice code. Thanks for sharing.

  • czar - thanks for the feedback!

    I've added some comments to the capx so that it's a bit easier to figure out what I've done (I was in a rush when I created it earlier and the first version was a bit gash).

    (edit - you see, I'm still not finishing my project....!)

  • I'm not using the beta release, I'm on r146.. does C2 let you save the project as an earlier version? I'd love to see it.

  • jobel

    Open the capx using 7zip or similar. Then right click on the .caproj file inside the root and select edit - you will see a notepad document containing the settings. 11 lines down is


    Just change the 151 to whichever version number you're using.

    I don't have dropbox access so I can't change it myself for you; when I get home I will edit it.

  • Colludium

    actually I just updated to 151 and looked at it. (I'll rollback to 146 later)

    Thanks! that's pretty much what I was talking about. Although I'd slow it down a bit. I'm making a semi continuous beam (I'll build in an overheat) and then when released I will decrease the width. So it looks like a continuous beam was cut off, not just stopped.

    I like the LaserBolt2 sprite.. did you make it? it's perfect.

  • Colludium Very nice and good example , I would like to thank you for you work. I love the examples of laser you have done. <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Thanks!

    I made the laserbolt sprite myself using the C2 sprite editor - I've found it to be a quick and easy tool for things like that.

  • hi Colludium ..I've been looking at your code and I'm finding the only problem is, if the target you are hitting is moving, then there's an issue where the sensor hits the target but then the growing laser never reaches it. So basically it shows the laser hitting the spot where the target was, opposed to where they currently are... The time it takes to show the growth of the laser is too slow for a moving target.

    I've been trying to add logic so that it uses the target's current x/y if the sensor actually hit them.. my problem is knowing what the sensor hit, if it's a bunch of different objects then I wonder if performance will be hampered. The laser should probably move slightly with the target (side to side) as well..

    I'll post it if I figure it out!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)