Issue With Lasers As Hazards

0 favourites
  • 3 posts
From the Asset Store
This is a pack of 14 animated lasers with different colors.
  • I really hope somebody can help me with this, it's been driving me crazy and completely preventing me from making any progress on my current project.

    Levels in my game have lasers scattered throughout the environment -- if the player gets hit by a laser they take damage, but if a moving platform gets in the laser's path it blocks it so the player can advance. Pretty simple stuff, really. Basically, the lasers should start at my Laser Emitter object, and extend in a straight line until they hit something -- a wall, a moving platform, or the player. (In case it wasn't clear, I'm talking about instant-hit lasers that span the entire distance between where they start and end, not bullet-style "laser blasts".)

    I started out using SamCartagenaPR's Laser Gun Effect method (try it here or get the .capx), but it's not quite perfectly suited for my purpose. The good news is that my lasers will never need to rotate or change direction in-game, which should simplify the necessary events.

    The bad news is I can't for the life of me figure out how to make it work with multiple lasers firing simultaneously. Worse, even with just one laser going the game's performance takes a significant hit, slowing the framerate by almost half while the laser is on-screen.

    I found a forum thread that addresses this exact issue, except it's in regards to Construct Classic. I'm not a talented enough event-programmer to figure out how to apply that info to working in C2.

    Like I said, I'm at a point where I can't really continue designing my game until I get this issue figured out. I really appreciate any assistance you all might be able to provide.

  • You could do lasers like this in post:

    http://www.scirra.com/forum/laser_topic44612_post279569.html#279569

    Make it work for multiple lasers by add a "for each laser" to the top of event two.

    You can adjust event two so that you get better performance by decreasing the repeat count and increasing the amount you lengthen the laser. It's just a balance between performance and accuracy, but also keep in mind that both numbers multiplied together also define the range of the laser. In the example the range is 30*20 or 600 pixels.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks ROJOhound! This method looks like the perfect solution for me, but there's still an issue with having multiple lasers -- namely, in event 1 when it sets the laser's position to the emitter's, it sets all the different lasers' positions to the same emitter.

    I'm gonna have to break down and learn how to pick instances by IIDs, aren't I? Dang, I've been putting that off because it makes my non-programmer's brain hurt...

    EDIT: Never mind, I made a simple mistake. It's working almost perfectly! I'll have to futz with the numbers to make it behave just the way I wanted, but this is definitely the solution I'd been looking for. Thanks so much!!

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