How do I differentiate attacking between enemy instances?

Get help using Construct 2

Post » Mon Apr 28, 2014 6:21 pm

I am using construct 2 to make a game for a college assignment. My team of three has been extremely enthusiastic so we have gotten a lot done in the past two weeks. However I keep running into a nagging problem. I have instance variables that tell our skeletons to set their animations to attack upon hitting the players aggro box. However, even though "engaging" is an instance variable, it sends out a global command. I've just started to read about UIDs but I'm not sure how to best implement them in this case.
You do not have the required permissions to view the files attached to this post.
B
4
S
1
Posts: 26
Reputation: 402

Post » Mon Apr 28, 2014 6:33 pm

It's difficult to really tell without seeing the full capx, but why are you using separate objects for enemy and enemy aggro? If you're following the recommended practice of using a bounding box (EnemyAggro in your case) for the actions and a sprite for the animations, you need to store all of the necessary data and behaviours in the bounding box object, and only pass on the necessary animations to the animation sprite.

From what I can tell, you're assuming that the bounding box knows which skeleton animation to trigger, and vice versa. It won't unless you specify that, so it's applying the actions to every instance. Depending on how your game is set up (or rather, you should set your game up in this way), you should be using containers to pair each skeleton to a bounding box so they always know to which instance you're referring. Read this manual entry on containers.

Also, you have loads of redundant "every tick" conditions there. Read this very important blog post.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Mon Apr 28, 2014 6:47 pm

Thank you for responding, when you say by adding containers it will differentiate between my instances, will that be automatic? Or do i still need to add multiple events for each instance? When you say enemy do you mean the red sprite? That is the skeletons dummy colisor sprite
B
4
S
1
Posts: 26
Reputation: 402

Post » Mon Apr 28, 2014 6:52 pm

Do you know of a good .Capx example where this method has been used before?
B
4
S
1
Posts: 26
Reputation: 402

Post » Mon Apr 28, 2014 6:57 pm

Oh, okay in that sense your events are even more muddled than I thought :P

Read through the containers manual entry for all the details, but essentially, containers make different objects behave together very well.

If you put the red sprite, aggro sprite and skeleton animation together in one container, when you have a condition that picks any of those objects, it will always pick the corresponding other objects in the container for the purpose of actions.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Mon Apr 28, 2014 7:06 pm

Here's a quick example I put together to illustrate the difference between events referencing objects in containers, and those not in containers. Hopefully it'll give you a clear visualisation of what's going on inside your game.

Also worth noting is that objects in containers are automatically created at the origin of their "parent" objects (although containers are actually flat and not in a hierarchy, they can still use root objects to create the rest of the container objects). Otherwise, if those objects already exist, they are paired according to the order in which they were placed in the layout.
You do not have the required permissions to view the files attached to this post.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Mon Apr 28, 2014 7:34 pm

What makes you call them muddled? They work perfectly well aside from our container issue, thank you very much I will give that a try.
B
4
S
1
Posts: 26
Reputation: 402

Post » Mon Apr 28, 2014 7:50 pm

Because the logic is wrong. The "container issue", as you call it, is at the root of the problems.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Mon Apr 28, 2014 11:18 pm

/
Last edited by DarkJokerr on Mon Apr 28, 2014 11:34 pm, edited 1 time in total.
B
4
S
1
Posts: 26
Reputation: 402

Post » Mon Apr 28, 2014 11:33 pm

I tried making both the skeletons new hit box and the skeleton itself a container for the other at separate times, but the skeletons still attack in sync
B
4
S
1
Posts: 26
Reputation: 402

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000, goodboy69 and 58 guests