How do I set 1 sprite onto multiple instances of an enemy?

Get help using Construct 2

Post » Fri Apr 18, 2014 12:50 pm

Hey all,

Im stuck, again :(

Im trying to find a way to get a sprite+animation to run on multiple instances of the same enemy. I need the sprite and animation to become visible and run only when each individual enemy is in a collision circle pinned to the player, AND for each instance to have its own sprite+animation running instead of having have ALL enemies in the collision circle for it to work.

This sounds confusing, so i will provide a screen shot:
regregreg.png


So when each enemy collides with that grey circle pinned to the player, they will each have their own sprite+animation run, but starting with only ONE instance of the sprite+animation which is currently off screen. I hope im making myself clear.

I have tried using things like "For Each "enemy" with 2 sub events and spawning objects and stuff and i cant get it working >.<

Thanks in advance for any tips/suggestions,
If you have any questions, please ask :)
moymoymoy
You do not have the required permissions to view the files attached to this post.
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Fri Apr 18, 2014 1:15 pm

Each time the player triggers a collision (the circle around the player) with an enemy, only that enemy's instance should be affected. I don't understand why all of the enemy instances are being triggered.

Look at this capx and tell me if this is what you want to achieve: http://www.eli0s.com/Tests/ScaredEnemies.capx

I am using a Boolean Variable on the enemies to check if they have being collided or not and when the Boolean is true, they change their animation and position.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Fri Apr 18, 2014 1:25 pm

Its not allowing me to open that capx because it is from version 167.2 and im on 163 which is the most recent version scirra is allowing me to download?

I just wanted to clarify though:

It is a seperate sprite+animation i want to add onto multiple instances of those enemies. Basically, it is an attack animation that will play over their current heads if they are within the circle.

Appreciate the response, thank you :)

Edit: i see it is the beta, i will grab it now ;)
Edit2: its not quite what im trying to achieve, i hope the clarification above explains myself better
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Fri Apr 18, 2014 3:20 pm

So, in essence you would like to spawn an other sprite and change the animation on the current sprite (the enemy) ?

Download the example capx again, I have updated it to reflect the above requirements.

And yes, it's the latest beta, sorry, I should have had clarified it :)
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Fri Apr 18, 2014 3:57 pm

Yeah kind of. Id like to spawn another sprite with animation (lets call Sprite1) on the multiple instances of an enemy (lets call this Sprite2).

I checked the capx and i see the "create object" being used. Is there an option that will allow me to delete the created object if it is not within the collision circle? This would mean that the Sprite1 created would be destroyed but ONLY on an enemy NOT in the circle.

I will continue to mess around and see if i figure it out but if you could help more, it would be greatly appreciated :)
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Fri Apr 18, 2014 9:28 pm

Ok, so,

1) You want each enemy instance (Sprite2) to spawn this Sprite1 every time the player's circle collides with the enemy.

2) You want each Sprite1 (which was created before) to be destroyed if the player's circle is not overlapping the "parent" enemy any more.

3) You want everything above to be independent from each other, every instance to it's own in relation to the player.

Considering all the above, this is the best I can think of right now.

http://www.eli0s.com/Tests/SpawnedIDs.capx

I am using a distance check instead of the collision polygon of the circle (I've left the circle visible for illustration purposes) and instead of spawning the Sprite1, I set it's opacity to 100 when the player is within the desired distance and to 0 when it's not.

You can trigger different animations or frame numbers by adding sub-events (if you change the animation, don't forget to add the "Trigger Once While True" under "System" conditions).

I have to admit, this is more difficult that I'd imagined, correct picking is a @#$% :evil: and I really don't understand why I had to use the "For Each" loop, since Construct 2 supposedly picks every instance internally by its self.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Post » Sat Apr 19, 2014 1:26 pm

Heya,

Ive tried an distance check copying your methods on that capx file. See below:
ghatyma.png


It gave interesting results. The distance check works perfectly so thank you so so much for that. However, the sprite that spawns (Sprite1) stays stationary and does not move with the enemy. Im thinking of just testing out the pin behaviour and pinning it to an imagepoint. I'll let you know how that goes.

Thanks a lot for your continued assistance. If there was a way to thumbs up your profile or rate your help, i would give you 10/10 :)

Edit: Sprite1 in that screenshot is actually called "Sprite5" just to make things more confusing :)
You do not have the required permissions to view the files attached to this post.
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Sat Apr 19, 2014 1:29 pm

Update: Pin behaviour and "Set position to" did not work.

This is certainly the most difficult thing ive encountered so far on C2 >.<
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Sat Apr 19, 2014 3:31 pm

Update: Together, both the pin behaviour and the "set to position" work lol. The only problem now is getting the sprite to mirror WITH the enemy as it moves along the platform and to be on the correct layer >.<

One thing after another lol *rolls eyes*

Thanks again for your help.
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Sat Apr 19, 2014 3:32 pm

Hmm, I think you don't use the Pin Behavior correctly. You don't have to pin on some image point, first you set up the position of the child object (the one that has the Pin Behavior) in relation to the parent and then you "fire" the "pin to" action. You can either set the initial position manually in the level editor, or with actions, just like in our example.

Please, re-download the last example, I've updated it to include the Pin Behavior. I used the Sine Behavior on the Enemy objects just to give some motion and pruve that the spawned object (Sprite1 or 5 or identity crisis :D ) follows.

No need for anything, I am glad if I was helpful, by helping others I also learn my self!

Tell me if everything works ok now
composer - multimedia artist
www.eli0s.com/en/
B
69
S
27
G
6
Posts: 1,146
Reputation: 10,379

Next

Return to How do I....?

Who is online

Users browsing this forum: richardfu, Yahoo [Bot] and 29 guests