How do I create a multi-targets homing missiles launcher

Get help using Construct 2

Post » Wed May 14, 2014 5:53 am

Greetings!

I am having a bit of an issue with my shooter here, let me explain :

- Attached to the body of my hero sprite is a gun/arm
- This gun/arm move 360 and an aim is attached to it
- When the right trigger of the controller is down, the gun shots bullets toward the angle of the aim.

So far so good, but here comes the part I can t really figure out how to do

- When the left trigger of the controller is down, the hero can lock-on targets within the range and sight of his gun/arm
- Each time a target is acquired, a locked-on sprite is spawned on each target
- On left trigger release, X amount (X=number of locked-on target) of homing missiles will be spawned from the player and each missile will go toward is own target.

I managed to get a semi-working multi lock-on system, but when I release the left trigger, only one missile is spawned and goes toward the first acquired target but not the others.

Any hint on how I could make that happen.

Thanks in advance.

PS : I am a huge beginner so please bare with my possible stupidity :)
B
4
Posts: 5
Reputation: 210

Post » Wed May 14, 2014 7:25 am

That sounds like it's just an error somewhere, since it works with one. But it's hard to find an error with just a description.
Can you make a stripped down version of just those routines to upload? (you may find the problem when you are stripping it down. Which happens a lot.)

My off the cuff plan of how I'd do it would be to:
1. Have the player mark each of the enemy to target.
2. Then "for each" on the marks, so it will cycle through each.
3. spawn a missile and give it an instance variable to hold the UID of it's target.
4. as the missile flies have it turn 1 to 3 degrees toward the target until it hits something.

I did missiles like that in Orbital Bomb Bounder, and I believe I had a sine affecting the angle, so they wobbled a bit in flight.
B
239
S
62
G
33
Posts: 903
Reputation: 40,562

Post » Wed May 14, 2014 3:59 pm

Thank you very much for your reply Paradox, your plan worked like a charm ;)

I still have an issue, since the condition is on trigger down, the game spawn an infinite number of target/sprite on targets, I ll have to find a way to limit it at 1. Maybe a variable on the target/sprite itself?
B
4
Posts: 5
Reputation: 210

Post » Wed May 14, 2014 4:54 pm

Can you add "Trigger once while true" to the event?

Or maybe check to see if that one is already targeted.

The variable may be easiest to implement.

(Another thing mine had in that game; they were bullets, so I was able to check distance traveled, which let me time them out when failing to catch the target.)
B
239
S
62
G
33
Posts: 903
Reputation: 40,562


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 8 guests