Solved - How do I check the name of an object inside a family?

0 favourites
  • 6 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have a Tower Defense game and a family of objects called "Icons" (there are 5 different tower icons inside this family).

    The "Icons" family has the behavior DragDrop on it.

    When I drag an object in this family, I need to kick off an event and that event needs to know which of the 5 tower types I am dragging, so I can place the correct TowerType at the drop location.

    In pseudocode, if these conditions are met:

    Icons -> On DragDrop

    Icons.ObjectType = "Tower1-Icon"

    Then is should do this action:

    Icons Spawn Tower1

    The problem is that second condition "Icons.ObjectType" doesn't seem to exist.

    When I have the "Icons" family selected, how do I know which of the objects inside it I am actually working with - what is the test for this?

    Tagged:

  • It think you are looking for ObjectTypeName

    ObjectTypeName

    The name of the object type for the given object. For example Sprite.ObjectTypeName will return "Sprite". When used as a family expression, this returns the name of the actual object type, never the name of the family itself.

    https://www.construct.net/en/make-games/manuals/construct-3/plugin-reference/common-features/common-expressions

  • It think you are looking for ObjectTypeName

    That is what I want to get, but it doesn't seem to exist as an option for a Family.

    When I go to add the condition and I select "Icons" (which is my family), there is no option after that for any ObjectTypeName.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure if this is the best solution, but I created an Instance Variable for the family "Icons"and filled it with the Tower Name for each Icon. Then I was able to reference that Instance Variable in the condition.

    It works, it just feels like an unnecessary trick, and I can't figure out a better way to do it.

  • When I go to add the condition and I select "Icons" (which is my family), there is no option after that for any ObjectTypeName.

    ObjectTypeName is an expression. You need to use a condition like "System Compare Two Values" to check it:

    Compare Two Values Family.ObjectTypeName="SpriteName"

    Make sure to pick the family instance first.

  • ObjectTypeName is an expression. You need to use a condition like "System Compare Two Values" to check it:

    Compare Two Values Family.ObjectTypeName="SpriteName"

    Make sure to pick the family instance first.

    That didi it! Thank you so much!

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