0 Favourites

Family problems :(

  • 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!

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

  • Hello blackhornet <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    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

  • 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

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • dropbox.com/s/gij66sod0b8ml2d/teamupWithTheRedDevils.capx

    haha thanks 99Instances2Go

    Nice little capx.

  • Me too, love you guys

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
98 7,598
norum82's avatar
norum82
Unread hot topic
51 3,201
faulknermano's avatar
faulknermano
Unread hot topic
87 5,376
facecjf's avatar
facecjf