[Question]Using the Enemy Formation Game Object

Just out of curiosity, is there a reason we use the enemy formation game object and the gizmos instead of just dragging the enemy prefab into our play space and creating enemy instances?

I have the same question. I understand why having the EnemyFormation object is useful, but I can’t see any particular use for the Position objects. And when your formation ends up comprising different enemy types, I imagine it’s going to be a bit more painful to code the generation of the enemies in the EnemyFormation script.

One reason i can think of is that makes it easier to animate.
Consider this:
The arrival animation ends up at coordinates(0,0,0) and the idle animation keeps the coordinates locked there. Since the enemy is a child to the position empty object, the animations are relative to that. ie the enemy ship ends at (0,0,0) relative to the position empty object ie. the local coordinates become (0,0,0)
If we just had a free enemy object the arrival animation would end up at (0,0,0) of the world coordinates for all enemy ships.

I found this out the hard way after messing with it in my own game.

2 Likes

That’s interesting - thanks for that. I haven’t got that far yet, so I’ll revisit when I get there.

It’s a bit of a pity that the instruction doesn’t come with any explanation of why an approach might suit or is important. As I’m going through the course, I’m keeping my own learning notes. However, when actions taken by the instructors seem arbitrary, it’s difficult for me to document anything that is going to be useful later.

For example, I guessed that having an EnemyFormation object might help in this type of game to have synchronised movement of all child enemies and to use its bounds to limit the movement of those enemies only because I have attempted to develop a similar HTML5 game from scratch and had to solve that same problem. I’m not sure if it would have been as clear to me if I hadn’t already had that experience.

I’ll continue on and if it all becomes clear I’ll retrospectively fix my notes up so that I can make proper sense of it all.

In working on a game of my own, I realized one thing this does allow you spawn different sprites easier. If you just dragged them on, you would be stuck with that one sprite, however by spawning sprites from an array of sprite game objects you can have different sprites moving a similar way.

Thanks for that. I also found that the way the game was going (wave after wave into the same formation) that using the Position objects made sense.

I think I might see some other uses now as well.

I ended up making the enemy formation a prefab, then created multiple enemy formations. The different formations are chosen at random each time a formation is killed.

Privacy & Terms