Subsitute for "move-to-family-event"?

0 favourites
  • 4 posts
  • Hey guys,

    I'm looking at a problem that surely has workarounds but as I'm always striving to improve my construct skills I am looking for a better solution from more experienced people.

    So it's a tower defense with the family enemies. That family contains - amongst other enemies - the enemy object wolf.

    Now I would like to have an invisibleWolf that has exactly the same animations and behavior as the normal wolf, with 2 exceptions:

    • its opacity is set to 50%
    • it's not part of the enemy-family yet, because I don't want my towers to shoot at it (they have the whole enemy-family set as target). ONLY if one special observer-tower "shoots" at it, the invisibleWolf becomes visible and all the other towers can shoot at it (as if it was just moved to the enemy-family).

    Now I could just destroy the invisibleWolf and create a normal wolf at the same position when the invisibleWolf is shot by the observerTower, but then the new wolf would first turn and need to find the path again so it would basicly stop there for a second whereas I am looking for a "smooth" transition:

    just turn the invisibleWolf into a normal wolf, as if that certain instance of the invisibleWolf was moved to the enemy-family (so that it becomes a target for ALL towers) and has its opacity set to 100%.

    It's problably not that easy so I am not disappointed if there's no quick solution. Then I'll just do it with a workaround. But thank you in any case.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You could have the invisible wolf not as a separate object type but as a normal wolf object, and have an instance boolean variable that tracks if it is an 'invisible' variant. When it gets shot by the observerTower, just toggle the flag (to make it shootable by normal towers) and bump its opacity to 100. If I've understood your needs.

    Another thing (more general) is to have more families than just 'enemies'. e.g. 'shootable' or whatever. You can have objects in more than one family to give you more control. It's 'kind' of like dealing with a class hierarchy that way.. kind of.

  • Okay thank you. If I understand this right though, I still need to check at some point whether the enemy has the instance variable isInvisible is set to true so that the tower does not shot at it and the only point where I could do that is at this event:

    On turret shoot

    So to that event I would add a subevent that checks if isInvisible is set to true and to that subevent I would an else where as action I would do the whole "spawn bullet"-thing.

    But this would be a bit too late I think because the turret still follows the enemy with its barrel, I just doesn't spawn bullets right?

    Thank you also for the general advice, I just think that in my special case, I'd kind of need the opposite of having the same object in two families.

  • You're right it might not be suitable in your case. Will have to think about it when I get a sec.

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