Making a laser

Get help using Construct 2

Post » Tue Aug 13, 2013 4:56 pm

Hi guys!

I'm trying to get this laser set-up I have going here working properly.

Laser Example

The objects are draggable, so you can see how it behaves.

The problem is the laser is penetrating into both the obstacle and the target. I know WHY it's doing that, as I have it set to target the X and Y of each object...but I don't know how else to do it =\

Anyone able to clue me in on a better way?

On a side note: Can anyone explain to me why this extremely simple capx is 36 mbs? -_-
B
19
S
7
G
10
Posts: 82
Reputation: 4,996

Post » Tue Aug 13, 2013 5:17 pm

Sorry could you explain further what you would like the laser to do or not do?
B
46
S
16
G
77
Posts: 2,154
Reputation: 45,821

Post » Tue Aug 13, 2013 5:23 pm

Yeah that would help wouldn't it? :P Sorry, must have gotten distracted by some technical issues I was having with Dropbox.

What I would like to have happen with the laser is for it to collide with the OUTSIDES of the obstacle and target sprites, instead of it going inside them they way it does now.

Like I said though, I can only get it to target the centers.
B
19
S
7
G
10
Posts: 82
Reputation: 4,996

Post » Tue Aug 13, 2013 5:26 pm

Here's how I usually like to go about lasers. You can play with those values to change the maximum range and precision.

It's a good idea to change the 'obstacle' object reference into a family reference (e.g. 'LaserBlocking' so you can have multiple objects block the laser, but I wasn't sure if you had the free edition).

I have no idea why it was over 30mb, that was really weird. I saved it as a project folder, then saved that as a capx, and that fixed it. Very odd.

sqiddster2013-08-13 17:28:12
B
92
S
31
G
24
Posts: 3,191
Reputation: 32,689

Post » Tue Aug 13, 2013 5:32 pm

I think it's to do with bbox. Something like (laser.x,laser.y,target.bboxright,target.bboxbottom) will have it stop on the right side of the object. I guess mess about with the bbox thing a bit as setting it to bboxright will only work when laser is on the right of the object and setting it to bboxleft will only work when laser is on the left of the object. Decent starting point though..
B
46
S
16
G
77
Posts: 2,154
Reputation: 45,821

Post » Tue Aug 13, 2013 5:41 pm

Oh wow, sqiddster. You got it to go around the edges of the circle and everything. Very nice :)

So close >.< The only issue now is to get the laser to stop at the outside of the target as well, instead of going all the way through it. Or at the very least for it to hit the center like it did before. I'd be happy with that too, I could just hide that with layers.
B
19
S
7
G
10
Posts: 82
Reputation: 4,996

Post » Tue Aug 13, 2013 6:06 pm

You have a 26MB folder called 'Sai 1.1.0 + brushes' inside that capx. Plus a shortcut to Photoshop among other things :) I guess everything in the project folder gets put into the capx when you do save as single file?
B
55
S
29
G
19
Posts: 1,520
Reputation: 25,650

Post » Tue Aug 13, 2013 6:12 pm

Wow what the hell? lol

No idea how that happened at all. I saved it to the desktop once as a project file though by accident. That must have been it. Weird though, I didn't place any of my desktop items inside it O.o

Anyway squiddster's version is far superior, so I'll just delete the old one.Kazan2013-08-13 18:14:01
B
19
S
7
G
10
Posts: 82
Reputation: 4,996

Post » Tue Aug 13, 2013 6:17 pm

Before you do too much math to get it to stop short, wouldn't it be easier to set the z-order and have the laser behind the obstacles? It would look like it hit the side.
B
233
S
62
G
33
Posts: 902
Reputation: 40,398

Post » Tue Aug 13, 2013 6:34 pm

I thought of that and even played with that idea before. And while that works, the laser (now) goes through the target object and out the other side of it, so it looks a little weird. If it stopped at it's center your idea would be perfect :)

The laser beam has to "collide" with the obstacle sprite though. There's no getting around that in my particular game. =\
B
19
S
7
G
10
Posts: 82
Reputation: 4,996

Next

Return to How do I....?

Who is online

Users browsing this forum: ditocruz, dop2000, mcscooter and 24 guests