Issue With Lasers As Hazards

Get help using Construct 2

Post » Fri Oct 05, 2012 6:38 pm

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.whiteheat2012-10-05 18:44:29
B
7
G
1
Posts: 27
Reputation: 991

Post » Fri Oct 05, 2012 7:28 pm

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.
B
79
S
24
G
54
Posts: 4,753
Reputation: 40,769

Post » Fri Oct 05, 2012 8:09 pm

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!!whiteheat2012-10-05 20:24:22
B
7
G
1
Posts: 27
Reputation: 991


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests