Problem with instances

Get help using Construct 2

Post » Tue Aug 05, 2014 9:05 am

Now here's probably something very basic I'm missing... It may lead to some more complicated questions so I'll post it here.
But I'll start simple, here I'll try to explain:
if you overlap the enemy with the crosshair and shoot (hold down z) the enemy turns red (animation frame 1), if the crosshair is not overlapping then it goes back to green (animation frame 0). This works fine if you have one enemy instance, but if you have several on screen and shoot them all they all turn red even though the crosshair is not overlapping them.
If you don't know what I mean then I think it will become clear if you look at the capx here:
https://dl.dropboxusercontent.com/u/98471899/Scirra/crosshair.capx
B
9
S
1
G
1
Posts: 42
Reputation: 1,213

Post » Tue Aug 05, 2014 9:21 am

Here is a fixed version for you.

crosshair.capx


Updated CAPX - Changed something that didn't need to change so put it back how you had it.

Also quick explanation why yours didn't work. You were checking if the "crosshair" wasn't overlapping "enemy" but if you are aiming at any other enemy you are "overlapping" an enemy so that event wouldn't be true.
You do not have the required permissions to view the files attached to this post.
B
46
S
23
G
7
Posts: 459
Reputation: 6,763

Post » Tue Aug 05, 2014 12:40 pm

Thanks!
B
9
S
1
G
1
Posts: 42
Reputation: 1,213

Post » Wed Aug 06, 2014 9:27 pm

Here's another problem with instances...
I tried to make some enemy ai:
The enemy keeps going left until he comes close enough to the player; then, after a little delay, he either swings his club or he goes to the right for a short interval and then swings his club, after that it's back to going to the left looking for the player again.
It works fine with one enemy on screen but if you add 2 more instances it messes things up somewhat.
Maybe there's something wrong with my approach here, but I don't understand why it works with one enemy but not with many.

https://dl.dropboxusercontent.com/u/98471899/Scirra/enemyexample.capx
B
9
S
1
G
1
Posts: 42
Reputation: 1,213

Post » Sat Sep 27, 2014 12:05 pm

And more... A bit clearer and better example than the last one.

https://dl.dropboxusercontent.com/u/98471899/Scirra/StarExample.capx

I have an enemy here going left or right and jumping at random, using the Timer behavior. With one instance it seems to able to go on forever but with two they'll get stuck after a while, may take a minute or two.
B
9
S
1
G
1
Posts: 42
Reputation: 1,213


Return to How do I....?

Who is online

Users browsing this forum: PRIZZRAK and 26 guests