Attach Sprite to other sprite problem

Get help using Construct 2

Post » Wed Sep 04, 2013 10:11 am

So by now I erached a point in my game where i have to place some enemies in a stage to test if their behavior does what it's supposed to do. So today i tried making a bat.

The bat hangs on the ceiling and sleeps. if the player comes close, the bat wakes up and flies around frantically. it tries to get the player, so if the player is out of range (aka turret range) the bat flies somewhere else until the player gets in range again. If the player hits the bat it dies.

So far everything i described here works like a charm. Here's what I did:
i created a enemy box. since i dont want the bat to titl at any angle but till fly in any angle, i gave the box all functions and simply attached a bat sprite to the box. the sprite has two animations: sleep and fly. so for starters they sleep nd then they fly. This, as wll, works perfectly.

Now here is my problem though:
once ONE bat starts to fly, ALL bats start their fly animation, even though they still sleep. furthermore, once all bats aredefeated, the last bat i kill is NOT disappearing. its gone, technically but the sprite still shows and has the fly animation on loop.

i did this:
B
7
S
2
Posts: 66
Reputation: 720

Post » Wed Sep 04, 2013 10:15 am

Me thinks you need to use a For Each EnemyBatBox command, to prevent them from all going at the same time.
Using R243 for all examples
B
69
S
20
G
6
Posts: 379
Reputation: 9,699

Post » Wed Sep 04, 2013 10:19 am

i tried that already but nothing changed.
In fact i tried it for bats and batboxes. nothing changed with abts and with batboxes all bats started flying at the same time but only one was visible.EzekielRage2013-09-04 10:21:49
B
7
S
2
Posts: 66
Reputation: 720

Post » Wed Sep 04, 2013 10:28 am

You are not picking the bat that belongs to the enemyba.

The easiest way is to create a container. That way only the bat attached to the enemyba is selected.

An other choice would be to add a condition - if enemybat is over enemyba. that way only the overlapping bat would be chosen.
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 » Wed Sep 04, 2013 10:49 am

i had a condition with overlapping but that didn't help either. I'll try a container and see how that goes^^

edit:
And that worked perfectly. As simple as that! fantastic, thank you!EzekielRage2013-09-04 10:54:33
B
7
S
2
Posts: 66
Reputation: 720


Return to How do I....?

Who is online

Users browsing this forum: dop2000, JackTYGA, zill and 33 guests