Family Question -- Resolved

Get help using Construct 2

Post » Sun Sep 28, 2014 7:21 pm

Resolved by

pick fam.uid that == fam.uid

the error came from nesting families - and derping >.>

Ok, I'm confused...

https://www.dropbox.com/s/ajnyf2yigovr4g7/familyIssue.png?dl=0
Image

This code affects every single member of the family, as opposed to each individual member of the family that ACTUALLY matches that criteria

Edit: Maybe i have not been clear in my description....

Create family - canDamg
- variables
-healthCurrent = <varies>
-healthMax = <varies>
-damgDealt = 0
-healTaken = 0

if canDamg is overlapping damgBox
trigger once
- set self.damgDealt = 6


if canDamg -- damgDealt does NOT equal 0
--- spawn damgText
----set damgText to Visibile
--- set damgText.Text = damgDealt
--- set canDamg.healthCurrent = to (canDamg.healthCurrent - canDamg.damgDealt)
--- set self.damgDealt = 0

this causes EVERY single object in the family to have damgText spawn and display the amount of damage done

it should only cause canDamg.mobA the slime beast who just got hit - show 6 damg dealt
Last edited by Effregy on Mon Sep 29, 2014 3:35 pm, edited 3 times in total.
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Post » Sun Sep 28, 2014 7:27 pm

You are not picking specific family members..

try using pick by comparison, or ofcourse for each..
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 » Sun Sep 28, 2014 7:28 pm

Containers and families do not work well together, so even if you are using them in that case, all instances of the text object are picked so all will be affected by the actions.

And if you were not using containers, then this is the expected result.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Sun Sep 28, 2014 7:38 pm

I haven't tried using containers, I'll look that up -- but i am picking specific family members -- all members of the "canDamage" family, who's damgDealt does not = 0

Edit: containers will not work for what i'm doing

- this code is designed to make text pop up over an enemy - with varying affects - colors ect - and i'm creating and destroying them so i can animate them in a satisfying way - critical hit - weapon effects - ect
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Post » Sun Sep 28, 2014 10:23 pm

Try doing a Pick where damgDealt=0, then a For each canDamg.
ImageImageImage
B
71
S
21
G
222
Posts: 3,652
Reputation: 124,733

Post » Sun Sep 28, 2014 10:29 pm

and adding the family.uid to the textobject as an instance variable so you can get the correct text for each family member (workaround for not being able to use the container)
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 » Mon Sep 29, 2014 11:55 am

doing a Pick where damgDealt=0, then a For each canDamg. showed me that every other expression i had involving families chose the first object in the family added to the project - that construct 2 can't pick out individual objects in a family that make a statement true - thus defeating the entire purpose of families

I've never used UID before, but I'll look into it

thanks for the replies
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Post » Mon Sep 29, 2014 1:43 pm

There is no reason it shouldn't behave as intended. Like you said, families were created for situation like these, where multiple object types share a common behavior. Could you post a capx with the issue so we can try to see what's wrong ?
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Post » Mon Sep 29, 2014 2:21 pm

I figured this would easily work as intended, and was in the process of creating destroy-able barriers and knockback from enemies inflicting damg to the player

also character takes a lot of fall damg, because it's currently based on air time as opposed to vertical fall distance

-------the error I came to the forums is housed in the damgText_Logic Event sheet
Last edited by Effregy on Mon Sep 29, 2014 8:25 pm, edited 1 time in total.
B
9
S
2
G
1
Posts: 36
Reputation: 1,381

Post » Mon Sep 29, 2014 2:39 pm

The problem stems from your usage of multiple families at once. Unless I'm mistaken, picking a particular family member, won't allow you to directly affect its family variables of another family without additionnal picking. I guess you could try to add a "Pick by unique UID" of every other family so only one object is ever selected.
B
67
S
28
G
24
Posts: 970
Reputation: 18,675

Next

Return to How do I....?

Who is online

Users browsing this forum: Sparkz and 1 guest