How do I have multiples of one sprite have own rules

Get help using Construct 2

Post » Sun Dec 27, 2015 5:29 pm

When I got my enemy ai working, I copy pasted the enemy sprite all over the layout and started playing. When I got to the first enemy, it shot a bullet but then every other enemy shot one when the player sprite wasn't even in the enemy range. How do I make it so that every multiple of the sprite had its own id/ai and know when to shoot?
B
3
Posts: 6
Reputation: 187

Post » Sun Dec 27, 2015 7:12 pm

Did you reference the correct enemy-sprite in the event?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 27, 2015 7:17 pm

Without looking at your capx I can guess you're using the system->compare condition with distance() expression to check the range. You can probably fix it by either using the system->"pick by comparison" condition to pick the objects in range or you could loop over the enemies with a "for each" condition.
B
91
S
31
G
103
Posts: 5,240
Reputation: 67,766

Post » Mon Dec 28, 2015 7:53 pm

R0J0hound wrote:Without looking at your capx I can guess you're using the system->compare condition with distance() expression to check the range. You can probably fix it by either using the system->"pick by comparison" condition to pick the objects in range or you could loop over the enemies with a "for each" condition.


Indeed I am using that exact command to check the range of the player with a range variable. Can you please tell me how do I incorporate your suggestions into an event form? I also don't know how to showcase my catman.capx. The range check command I am using for my enemy is " (RangeVariable) is Greater or equal to distance(Gunman.X,Gunman.Y,Player.X,Player.Y) " and that is for one sprite. I want it so that only the enemy that has the player in range to attack.
B
3
Posts: 6
Reputation: 187

Post » Mon Dec 28, 2015 11:46 pm

add a second condition to that (for each (player/enemy)) so it checks which is active.
B
29
S
13
G
10
Posts: 355
Reputation: 8,317

Post » Tue Dec 29, 2015 12:09 am

@Asdasing There's a few ways you can do this.

You can add a condition for "For each" along with your 'within range' condition. It'll check every single enemy separately to see if it is within range.

Also, you can set an instance variable to an enemy UID and use that to compare.
Check out my games on Google Play:
BEAST ATTACK (991,300+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
51
S
16
G
2
Posts: 428
Reputation: 5,291

Post » Tue Dec 29, 2015 3:10 pm

@jook00
@Carbincopy

Along with the range checking event, I have added the " System -> For each Gunman " and what it did is so that each copy (not clone) of the sprite only shoot if the player is within the range of EVERY enemy. This probably means that the condition is checking for every copy of the sprite to meet its condition and only then the action plays. The other method to check and compare the UID of every enemy sprite copy I do not know how to do. If you can explain it that would really help. Thanks otherwise.
B
3
Posts: 6
Reputation: 187

Post » Wed Dec 30, 2015 12:45 am

@LittleStain

I am not using multiple sprites, I am using copies of one sprite. Suggest whether it is better to make many sprite enemies and put them in a family or my way. And then explain the method of referencing the correct sprite, because that could be useful later for my game. Thanks.
B
3
Posts: 6
Reputation: 187

Post » Wed Dec 30, 2015 1:28 am

@Asdasing Does this work for you?
- Set up "For each" enemy
- set instance for each enemy and put the distance in that. I think you originally set up distance to select all enemies rather than using the enemy object as a condition. This allows you to now use enemy as the condition and compare the instance (distance to player).

https://dl.dropboxusercontent.com/u/73836006/enemyShoot.capx
Check out my games on Google Play:
BEAST ATTACK (991,300+ downloads!)
ZOMBIE BASH (Android) (Launched Feb 17)
ZOMBIE BASH (iOS) (Launched March 17)
B
51
S
16
G
2
Posts: 428
Reputation: 5,291

Post » Wed Dec 30, 2015 11:11 am

@jook00

System -> Every tick / Gunman Set Range to distance(Gunman.X,Gunman.Y,Player.X,Player.Y)

LoopSystem -> For each Gunman
Gunman -> Range Less than 250 / System Set group "Rapid Attack" Activated

LoopSystem -> For each Gunman
Gunman -> Range Greater or Equal than 250 / System Set group "Rapid Attack" Deactivated

The result is still the same after I made my events for my enemy like this. Every enemy needs to have the player in range so that all of them attack. My game is also a platformer and not a top down shooter, however I definitely do have very nice ideas for a top down shooter after Catman ;)
B
3
Posts: 6
Reputation: 187

Next

Return to How do I....?

Who is online

Users browsing this forum: jasontoups, Rudi55 and 1 guest