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

Just started using Construct 2? Post your questions here

Post » Mon Aug 18, 2014 9:44 pm

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.
B
13
S
2
Posts: 21
Reputation: 721

Post » Mon Aug 18, 2014 10:42 pm

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.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Tue Aug 19, 2014 12:39 am

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.
B
13
S
2
Posts: 21
Reputation: 721

Post » Tue Aug 19, 2014 12:51 am

You're right it might not be suitable in your case. Will have to think about it when I get a sec.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596


Return to Beginner's Questions

Who is online

Users browsing this forum: TrialnError423 and 0 guests