Container/Family/Multiple instances behaving independently

Get help using Construct 2

Post » Tue Mar 11, 2014 11:54 am

Hi, I have attached a sample file. I would like someone to edit the file (fix it first).

EnemyBox acts as the enemy.
Enemy object's only purpose is animation, nothing else.

If AI = 0 and every X Seconds, AI should go to either 1 or 2, to which it should walk right or left, respectively.

AI is not resetting (I think).

Please fix it and also I am requesting how multiple instances that behave independently but using same event/s. In this case, after fixing the "AI not resetting" issue, multiple instances of the Enemybox should already result in the instances walking left and right independently.

I already used containers.

Thank you.

P.S.
If you are using the newest versions of C2, please give me a screenshot of the events instead. I have problems downloading using direct download (torrent is working but super super slow download speed).
You do not have the required permissions to view the files attached to this post.
Last edited by sgn15 on Tue Mar 11, 2014 4:04 pm, edited 1 time in total.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Mar 11, 2014 1:19 pm

Did you want the enemy to "patrol" on the platform ?

If yes, check this :
AIpingPong.png


Tell me for this then I ll check for your second request.
You do not have the required permissions to view the files attached to this post.
B
39
S
15
G
5
Posts: 295
Reputation: 6,089

Post » Tue Mar 11, 2014 1:45 pm

uhm, that file was based from the original file I was making (but the original file was too complex with many variables to show to anyone), so I made this simplified file. The logic of the AI I used in that simple file is the same from my original file.

I found out just now that I made a mistake in this condition

+counter>=40
-> Set Counter to 0

It should be like this:
+counter>=40
-> Set Counter to 0
-> Set AI to 0

The attached file is now fixed. While this file is simplified version of my original file, I learned an idea from you (using the condition "has a wall to the right/left"), so thank you.

Based on the attached file in this post, I would like to ask questions:
In my original file, I use families instead of objects.

Objects:
Enemy
EnemyBox

replaced by

Families:
Enemies
EnemyBoxes

but same conditions.

Result: only 1 instance is actually moving according to the events. The other instances of EnemyBox is not moving, but the other Enemy objects are using the same animations as the only working Enemy object.
You do not have the required permissions to view the files attached to this post.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Mar 11, 2014 3:27 pm

sgn, I think this is what you are looking for:

Image

Basically, if you want to change an aspect that is going to be different in each of the instances of the object, you should use "for each [object]" condition as seen in the picture. I couldn't understand what you want in the post, but I am sure this is going to lead to your answer.

Hope it helps.
B
18
S
4
G
1
Posts: 332
Reputation: 3,149

Post » Tue Mar 11, 2014 3:49 pm

I want to do everything in the latest file I posted but using families instead of specific objects (in both conditions and actions). It seems it's really not possible to do that using families?

I need to use families because I have several other enemy types and they all have the same AI rules.

Basically, let's say I have 3 enemy types:
soldier
fighter
gangster
those 3 above are under the family ENEMIES

each of those 3 have their corresponding collision box
soldierBox
fighterBox
gangsterBox
Now these 3 are also under another family ENEMYBOXES

Now I use ENEMIES and ENEMYBOXES in my events. They don;t behave independently anymore. Is this how it really works in C2? Because I just tried in another blank file, the same exact events but using specific objects, they behave independently. So basically, I found out the problem already. C2 doesn't allow me to use families in events.

I can make a workaround for this by making 3 sets of same events, 1 for each enemy type, just triple the work. But I thought the essence of families was for this issue? That's what I was wondering about. Please answer. Thank you.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Mar 11, 2014 4:03 pm

Here is the proof of what I am saying

this is the same file from my last uploaded file here

changes:
-replaced all objects (in all conditions and actions) into families
-the behaviors and variables used are from the family, not the objects

now test the file, the enemy (animation object) doesn't behave independently anymore (especially the mirrored or not mirrored action)

Is this a bug with families? because I already read the manual on families and what I am trying to do should work with families (as far as I understood).
You do not have the required permissions to view the files attached to this post.
B
16
S
7
Posts: 301
Reputation: 2,726

Post » Tue Mar 11, 2014 10:02 pm

I had some trouble trying to figure out what you wanted to do.

So i actually started from scratch. (you made a lot of stuff different from how i would do it)

here is how i would do it with families:

https://dl.dropboxusercontent.com/u/2560922/mobiledev/forum/families.capx

The reason why your sample is not working is because of how you do "picking". But hey.. I still get confused about picking :)
B
20
S
6
G
4
Posts: 347
Reputation: 4,451


Return to How do I....?

Who is online

Users browsing this forum: alanziy, rayolf and 8 guests