Individual enemies

For questions about using Classic.

Post » Tue Mar 06, 2012 8:25 pm

I've got some snowman enemies in my game.

If the snowman is in collision with a snowblock, then the snowman will jump on it untill it's broken.

The problem is: all snowmen in the map are jumping if ONE of the snowmen is touching the snowblock!

So, I'm actually looking for a way to make all the snowmen individual of each other.

I hope you can help me! :) Here's a screen of the three main events.

B
21
S
6
G
3
Posts: 64
Reputation: 2,924

Post » Tue Mar 06, 2012 10:23 pm

On multiple objects to specify to construct which one you want to work on, you should use that object on event.

Like, if you use smth "on collision between something and snowman => jump snowman" than your action works. But if you use like " on collision between a and b => jump c" than construct jumps your all c objects. Beceause there is nothing to specify any c object.
B
7
S
1
G
1
Posts: 76
Reputation: 904

Post » Wed Mar 07, 2012 3:57 am

All You need to do is filter the "picked" instances of the snowman object.
The "For Each Object" loop is very helpful here.
It will check for each of the snowman objects individually and in its current check only apply to the current picked snowman instance in the loop.

So if You did something like:

+ For Each Object("snowman")
+ Snowman: On Collision with ("snowblock"?:
-> Do whatever You want that particular snowman, who is currently colliding to do.

You need to remember, that the Events will filter the picked instances of any object.
Then the Actions next to the Event will only be executed on the Objects/Instances filtered/mentioned by the Events.
B
3
G
1
Posts: 70
Reputation: 615

Post » Wed Mar 07, 2012 7:49 am

That's not quite the actual problem here. The "on collision"-condition will select any two instances involved in a collision, not every instance. For example, if you have two sprites, "red" and "blue", and both sprites both have 10 instances, and you create the following event:

+ Blue: On collision between Blue and Red
-> Red: Flash for 1 seconds with 0.1 seconds interval
-> Blue: Flash for 1 seconds with 0.1 seconds interval

then only those instances who are currently colliding, will flash. If only one blue instance collides with one red instance, only those two will flash.

However, in event 21 of Thijsku's image you can see that not the snowman and the snowblock, but a third sprite and the snowblock are tested for collision, so only those two are picked and not a snowman. The right snowman instance has to be picked manually in addition. For example by using

++ Snowman: Pick closest to: Sightsnowpop.X, Sightsnowpop.Y
--> (paste actions from event 21 here)

but that depends on what purpose Sightsnowpop serves.

Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Wed Mar 07, 2012 9:50 am

[QUOTE=tulamide] That's not quite the actual problem here. The "on collision"-condition will select any two instances involved in a collision, not every instance. For example, if you have two sprites, "red" and "blue", and both sprites both have 10 instances, and you create the following event:

+ Blue: On collision between Blue and Red
-> Red: Flash for 1 seconds with 0.1 seconds interval
-> Blue: Flash for 1 seconds with 0.1 seconds interval

then only those instances who are currently colliding, will flash. If only one blue instance collides with one red instance, only those two will flash.

However, in event 21 of Thijsku's image you can see that not the snowman and the snowblock, but a third sprite and the snowblock are tested for collision, so only those two are picked and not a snowman. The right snowman instance has to be picked manually in addition. For example by using

++ Snowman: Pick closest to: Sightsnowpop.X, Sightsnowpop.Y
--> (paste actions from event 21 here)

but that depends on what purpose Sightsnowpop serves.

[/QUOTE]
Yeah, You're absolutely right. I forgot, that the collision event already filters the instances. But I also couldn't see the image he posted, again because almost every foreign image hoster is blocked here (China), unless I unblock them (on a side note, lol).Shindoh2012-03-07 09:50:28
B
3
G
1
Posts: 70
Reputation: 615


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests