Family Question -- Resolved

Get help using Construct 2

Post » Mon Sep 29, 2014 2:47 pm

On event sheet healthBar, event 10, you are checking for tookDamg, but you aren't picking the single enemy-health objects, so all are showing. You need to maybe use a container to associate those items and use a UID to pick one item that is linked to the enemy.
ImageImageImage
B
71
S
21
G
220
Posts: 3,649
Reputation: 123,727

Post » Mon Sep 29, 2014 2:50 pm

There are some issues, and finding the specific reason is not likely to be one thing. :)
The first thing that will cause you issues though are that you do a "for each canDamage" however this family is not the same as genEnemy. So even if you do a for each canDamage and then do genEnemy is overlapping Damgbox. the for each have no effect as these are completely different objects to the program. so it selects all genEnemy objects.

The way you use for each is a bit wrong or misunderstood. And doesn't really do anything in this case.
Normally when you need for each is when you need different things to happen to a range of objects. So placing it as the very first condition is not very common as its not really needed in most cases.

The normal way of using it would be for something like this, if we imagine that a bomb explode in the middle of some enemies.

First you need to pick all the enemies that are hit (Enemies overlapping explosion) This will select X amount, lets say 5 enemies.
Each of these enemies we want to fly in random directions. So we add a for each Enemy as the last condition.

And then in the action, we do:
Set Enemy.position X = random(300)-150 Y= random(300)-150
(This is just simplified for the explanation and wouldn't work correctly :))

Which will set each enemy position to a random X,Y within that range.

So first you isolate the objects you want to work with and then you do something for each of them.

In your case you might be able to solve it if you after the for each in the top of the event add a "Pick genEnemy.UID = canDamage.UID"
Since these two families have the same UIDs, however I don't know your program well enough to know if that will fix it completely or not :D

Image
Last edited by nimos100 on Mon Sep 29, 2014 3:01 pm, edited 2 times in total.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Mon Sep 29, 2014 2:58 pm

@nimos100 pointed the faulty events. Remove both "For each canDamage", and put a "Pick canDamage with UID = genEnemy.UID" under the "Is overlapping". This way, both the genEnemy and canDamage will refer to the same instance.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Mon Sep 29, 2014 3:07 pm

Just another thing that you probably would like to solve. Your enemy_health_bar is going nuts and keeps creating them none stop. Just if you weren't aware.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Mon Sep 29, 2014 3:12 pm

if i use pick by unique uid - wouldn't that still present the issue of being unable to choose the individual object's uid that is being affected? - since i broke the family system and am unable to make code affect individual members -----

or am i missing something lol

Edit: had no idea about how it was constantly making health bars - that system is very much infant stages lol
- you're sure it's not just that it can't tell if the object has taken damg?
because that health bar is supposed to be invisible until it takes damg for the first time - but im having the same issue where it cant single out objects in a family - in the event sheet - since when one object takes damg - all the health bars appear - though im not sure how it's variable is reacting to that - since it should stay false :(
Last edited by Effregy on Mon Sep 29, 2014 3:17 pm, edited 1 time in total.
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Post » Mon Sep 29, 2014 3:13 pm

Yeah, there are a lot a simple mistakes here and there. You ought to revise your code a bit ! ;)
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Mon Sep 29, 2014 3:21 pm

Effregy wrote:if i use pick by unique uid - wouldn't that still present the issue of being unable to choose the individual object's uid that is being affected? - since i broke the family system and am unable to make code affect individual members -----

or am i missing something lol


As Magistross said there are some complications :)

But it shouldn't prevent you from picking individual family members, you just have to make sure that you work with the correct families. So if you pick a canDamage and then need a genEnemy all of the sudden in that event you have to add that:

Pick genEnemy.UID = canDamage.UID

Which in it self is not to bad and can be quite useful in a lot of cases. But it ofc complicate things a bit if you didn't do it on purpose, as some of the code might not have been made with this intention. And the way you created the families might not really work as well as you thought. And that will cause some complications at some point....most likely :D
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Mon Sep 29, 2014 3:23 pm

Effregy wrote:Edit: had no idea about how it was constantly making health bars - that system is very much infant stages lol
- you're sure it's not just that it can't tell if the object has taken damg?
because that health bar is supposed to be invisible until it takes damg for the first time - but im having the same issue where it cant single out objects in a family - in the event sheet - since when one object takes damg - all the health bars appear - though im not sure how it's variable is reacting to that - since it should stay false :(


No I noticed as I tested your game, that after a while there were 77000 objects, which is pretty uncommon.

But you can always run it in debug mode then you can see that it keeps making them.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Mon Sep 29, 2014 3:33 pm

holy crap it works now - thank you thank you
-- this is actually my second rebuild of the game - previous "installments/versions" didn't have these systems
since i was having trouble with convoluted means of choosing animations for actions
-- first time using functions for example lol
-- and for each >.>

-- also made that last comment before seeing yall's previous ones
./ignore it =]

Edit: and i was late lol

No I noticed as I tested your game, that after a while there were 77000 objects, which is pretty uncommon.

But you can always run it in debug mode then you can see that it keeps making them.

I haven't run the game in debug mode, but i've gotten no lag lmao - so i had no idea

As Magistross said there are some complications :)

But it shouldn't prevent you from picking individual family members, you just have to make sure that you work with the correct families. So if you pick a canDamage and then need a genEnemy all of the sudden in that event you have to add that:

Pick genEnemy.UID = canDamage.UID

Which in it self is not to bad and can be quite useful in a lot of cases. But it ofc complicate things a bit if you didn't do it on purpose, as some of the code might not have been made with this intention. And the way you created the families might not really work as well as you thought. And that will cause some complications at some point....most likely


probably true lol.. *crosses fingers*
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Previous

Return to How do I....?

Who is online

Users browsing this forum: Alvaro2 and 15 guests