Enemy AI and Firing Range

For questions about using Classic.

Post » Tue Mar 29, 2011 7:59 pm

Hi All,

I'm trying to create an enemy that has a custom firing range for each instance of aforementioned enemy. For example, I only want Enemy A to fire a missile whenever the player is within range of it. The problem I keep running into, however, is that if the player is within range of Enemy A, the firing behavior is triggered for Enemy B, C, and D.

Is there any way I can do this without creating a unique enemy object for each enemy I want to place in my level?

Thanks
-Letaceo-
B
1
G
1
Posts: 7
Reputation: 439

Post » Tue Mar 29, 2011 8:30 pm

[quote="Letaceo":2doqwkrc]
Is there any way I can do this without creating a unique enemy object for each enemy I want to place in my level?
[/quote:2doqwkrc]

Of course this would work with instances of the same object. I guess you have a picking mistake in your event setup.

Like this it would work for example for multiple instances:

[code:2doqwkrc]+ Evil: Value 'Range' Greater or equal Distance(Evil.X,Evil.Y,Player.X,Player.Y)
-> Shoot
[/code:2doqwkrc]

Evil being the Enemy sprite. Using the 'Compare a private variable' condition works great for picking here. It wouldn't work well if you used system compare for the same purpose.

Obviously I don't know your events, but as I said you are probably doing something in a way that all instances actually get picked, although you don't intend to.

Upload a cap or show your events if you're still having trouble with this.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,440

Post » Tue Mar 29, 2011 8:58 pm

That completely solved it. Many thanks.
B
1
G
1
Posts: 7
Reputation: 439


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests