Multiple Instant-Hit Lasers

For questions about using Classic.

Post » Tue Jun 19, 2012 2:49 am

So I made a simple constant-stream laser turret that shoots vertically. I used the instant-hit laser tutorial to set it up. My goal is to have more than one turret and each laser-length will be set independently. What I have working: two lasers on-screen (or more) with independent lasers and independent ending markers for calculating the length. They're the white dots floating in the air above each laser (tough to see). I want the player to 'break' the beam and shorten it. Simple enough, but assigning to multiple lasers independently alludes me completely.

What currently happens: If the player enters the beam on the left, both lasers lengths are shortened. If the player enters the beam on the right, nothing happens.

What I want: Each laser should be adjusted independently. I haven't a clue how to achieve that.

A shot for reference:


My current events:


vert: the turret thing
redbullet: bullet behavior object, instant-hit, invisible
rayend: set to last point of bullet, for judging distance
laser: duh
Sprite: player character

Any help is appreciated!C-72012-06-19 02:55:26
B
90
S
32
G
14
Posts: 935
Reputation: 14,540

Post » Tue Jun 19, 2012 9:28 pm

Haven't much time right now, but you said you want make each laser independent, but in your event is a global var. For independent actions, I only use private variables. So when the player overlaps a bullet and global var is 1, it destroys the bullet. That condition always goes for every bullet because the variable has to be a private one.

I would use the sprite that spawns the laser ingame, and that one spawns the bulle. And set floating to a private variable of that sprite.

Only work with global vars if your action also should be "global"/"'un'independent", for everything.
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Tue Jun 19, 2012 10:16 pm

That global variable 'floating' isn't related to the length. That is only used to determine if the player should get hurt or not (the player has a shield below them at times). I don't use that variable in determining laser length. It can be ignored for the purposes of this. Even with private variables, I'm not sure how I'd achieve it, but I suppose I can try a few things more later on tonight.
B
90
S
32
G
14
Posts: 935
Reputation: 14,540

Post » Tue Jun 19, 2012 10:35 pm

if you could make a small example .cap that shows the error, I can help you real quick.
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Wed Jun 20, 2012 12:17 am

I had a similar problem while developing final stages in Rules of the Shadowrealm. Make an example.cap and I'll try to help you too.Wolod2012-06-20 00:17:33
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Wed Jun 20, 2012 2:39 am

Here's a barebones .cap to show the issue.

www.adamprack.com/laserfix.cap
B
90
S
32
G
14
Posts: 935
Reputation: 14,540

Post » Wed Jun 20, 2012 6:00 am

It's just one way to do it. Maybe someone else has a better one.
https://dl.dropbox.com/u/26932498/laserfix%20%282%29.cap

edit: you don't have to put the laser itself and the rayend if you place a "vert" sprite. I've put them in one container. You only have to set a vert somewhere and the laser/rayend creates automaticly.
Just the first laser has to have all sprites, since they have to be at least 1x at the layout to exist^^zyblade2012-06-20 06:08:11
B
24
S
9
G
2
Posts: 294
Reputation: 3,160

Post » Wed Jun 20, 2012 12:39 pm

Hey, nice example zyblade! That was exactly my solution form Rules of the Shadowrealm!
B
54
S
11
G
4
Posts: 250
Reputation: 5,074

Post » Wed Jun 20, 2012 2:35 pm

Hi there is an example...

Lasers.cap

Get fun!

PD: Blight looks nice! good job!

Sorry for my english ^_^
B
4
S
1
G
1
Posts: 69
Reputation: 863

Post » Wed Jun 20, 2012 2:54 pm

Awesome, thank you all very much!
B
90
S
32
G
14
Posts: 935
Reputation: 14,540

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 10 guests

cron