How do I get an instance variable from a specific UID?

0 favourites
  • 3 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • As the title says. More specifically, I'm trying to use the 'Subtract from' tool to subtract a predetermined value that's taken from an instance variable owned by a specific UID.

    I'm trying to come up with the basic structure of a turn-based combat system. Through the use of family, instance variables and an index array I've managed to be able to pick up the current sprite's (enemy) UID. But is it possible to fetch its instance variable value (damage) as the subtraction number?

    Something tells me that it should be feasible within the Value input of the mentioned tool but I'm having difficulties on grasping how to write something past single values gathered from the 'Find expressions' list.

    In my mind: Subtract the value taken from the named instance variable of picked instance UID.

    Also, if there's any handy guide that I can take part of on how to understand and combine lines within the value input that is used within several tools that would also be really appreciated.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not sure if I understood your question, but usually you pick an instance and then you can access its variables using a simple Object.variable expression.

    Pick Enemy by UID=123 : Subtract Enemy.damage from Player.health
    
  • Thank you dop2000 ! Your line made me realize my miss. The so called enemies are part of two families. One is used in combination with the array to sort entities based on a "speed" value before combat. The other family is the initial one hosting their instance variables. I just had to change the family to pick instance UID for. The instance variables weren't listed under the speed family.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)