Family problems :(

Get help using Construct 2

Post » Tue Apr 11, 2017 8:01 pm

Hello :)

I need to have access to a specific objects instance variable when it's put in a Family. But I do not manage to do it.


My problem is like this:

I have two different sprite objects ( it's a bot and a human player ) and have put them in a Family.
The objects has an individual instance variable called (Team).
I need to have access to this variable to determine which team a bot/player is in. I need this so the bots does not attack a bot/player from same team.



I've managed to select the two different objects individually by identify them by their .UID... So I can perform operations on objects independently, for example a bot attacking another bot OR player, even though they are different sprite-objects.

But I need determine on which team a bot/player is in. I need to be able to access the sprite-objects instance variable somehow?

You should know I'm making a Multi-player game. And I have human-players connected on the network and then I have bots.
I have two teams. Blue and Purple.
I could not use the Peer-object ( the human players object ) for the bots. Cause in multi-player it needs to be associated with a connected peer. So I had to create another separate sprite-object for the bots.

I needed the bots be able to target both the other teams human players and the other teams bots.
I make this happen by using the turret-behaviour. Cause then I can get the objects UID that a certain bot has targeted.
This way I can make a Function and perform things to that object - and with the Family option in Construct I can do things in-spite they are different objects.

I cannot have the turret behaviour do everything automatically - cause I have an intricate Finite State Machine working as the AI for the bots. And in certain situations the turret behaviour just don't work.
I know I can use the the turret behaviour it self and add objects to the turret ( Add object to target ). But I can not do this in this situation cause it's very specific conditions and other things in play on how the bots attack ( the enemy )
And it would not work anyway - cause how would the turret know which team he is firing on?
Perhaps I could do something when a bot or player gets created and add that to the turrets targets - but... don't know.
Or make an Array with a teams enemy-players and -bots that contains their UID and SelectedTeam.
...It would be much easier if I just could access the objects instance variable: Team


Anyhow, thanks for reading this far :) At least I got to evaluate my problem even further when writing this topic.
Thanks!
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Tue Apr 11, 2017 9:02 pm

Put the instance variables in the Family, then they are available from both Family and Object.
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Post » Tue Apr 11, 2017 9:16 pm

Hello blackhornet :)

I think I understand, I'm experimenting with it right now. I haven't quite learned how the mechanics work yet with the Family instance-variables.
Can I make an instance variable in the Family ..say called. Team and make the individual objects set their own value in there - and later if I pick that object by UID get the variable they stored there?

I also found an interesting tutorial on the scirra-site that may be helpful: https://www.scirra.com/tutorials/556/un ... o-families
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Tue Apr 11, 2017 9:26 pm

blackhornet wrote:Put the instance variables in the Family, then they are available from both Family and Object.


YES, now I understand :) :) I think I've got it now. THANKS!
You saved me :)
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Tue Apr 11, 2017 9:41 pm

B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Apr 12, 2017 10:18 am

99Instances2Go wrote:https://www.dropbox.com/s/gij66sod0b8ml2d/teamupWithTheRedDevils.capx?dl=0


haha :) thanks 99Instances2Go
Nice little capx. :)
Soulmachine @Soundcloud
B
14
S
2
G
1
Posts: 63
Reputation: 928

Post » Wed Apr 12, 2017 1:11 pm

Me too, love you guys :)
B
4
S
1
Posts: 3
Reputation: 306


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Phacanu, richcoz81, Txchaser, Yahoo [Bot] and 27 guests