System Create object by name for specific family

  • Hello,

    I have 2 families, Enemy, Friendly with the same objects in each of them (Soldier, Catapult in example)

    How can I create a catapult of family Friendly? I hoped for something like "Enemy.Catapult" but i cannot find something like that in the manual or tutorials.

    If I cannot create (same) objects for different families, I do not understand why I would ever use two families if I have to dynamically create objects in the game.

    Many thanks

    Nico

  • Oh right if it's the same object type in both of those families then it probably won't work correctly, depending on how the game is, but I imagine it won't. You use families to apply the same logic to multiple objects, not for creating 'for a family'. I would return to the isFriendly variable and ignore families altogether for this game and just be careful with the picking.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You shouldn't use families for spawning like that. what you can do is:

    local number UID = 0

    decide to spawn catapult / melee

    create catapult / soldier

    set UID to catapult / melee.UID

    then pick friendly with variable UID

    set isFriendly to differentiate between Friendly Unit and Enemy unit

    treat both objects the same...

    ____________

    P.S.:

    when you create a catapult, it will automatically be a member of BOTH families (all families that you assigned it to), so you can pick either friendly or enemy with UID

    Also: the Familiies dont help to differentiate between enemy/friend if both objects are in both families.

  • Thank you.

    It sounds awfully much effort for a very simple condition. The goal is that if a unit is in range of another unit which has a different isfriendly value of this unit, the fight animation is played.

    I try this now for 2 days and cant get it done :- (

  • Reluctantly I did it now the (very) ugly way... How to optimise that, i was sure in construct someone manages that with 2 conditions or so ;- )

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