Starting first game: some basics req'd

Hi, I’m at a stage where I feel at ease with the Unity environment and have the basics needed to start a game. I have all the pieces but just need aid in putting the jigsaw together.
I plan on making a space game a little similar to Galaga. I plan to use prefabs for the rows of invaders. So first Q: Should I ‘build’ the scene i.e place the invaders on screen in their rows ready to attack or should I make a function to create/instantiate them within the code and position them from there? The latter would make it easier to reform the attack waves on new levels, am I right?

2nd Q: I’ll need a single vader to randomly make the swooping attack. How do I address a single vader to do this? To single out an instantiated clone should I tag each invader with a unique tag i.e enemy1,enemy2 etc or are there other ways of sending events to a chosen unique clone.

Sorry to go on with such basics, but any help will be appreciated as I expand into Unity’s world. My Q’s will get more advanced I promise.

Yes, spawning waves dynamically would likely be the best way for this type of scenario. It’ll be easy to vary the configurations procedurally, as well it would be highly impracticable to create literally a hundred iterations each in a separate scene.

It’s been so long, what 30 years?, since I last played Galaga. I can’t remember exactly how the ‘attacking’ guy actually worked. If it’s simply a random individual you could at the start of each wave build an array containing all the game objects with the tag “enemy” and select one at random when you need it.

 var objectArray : GameObject[];
 objectArray = GameObject.FindGameObjectsWithTag("Enemy");

That way, you’re not doing relatively slow find operations in the middle of the game, but pushing all the computation to a time when nothing’s really going on.

Many thanks for the info Quietus. I have a hunch over which way to go with my code but it’s better to have it confirmed by users such as yourself. I just need some hints on the collision stuff. I’m using pseudo sprites, 3d planes, and wondered if there are any options other than making them is kinematic and checking is Trigger. Would making, say, 20-odd moving aliens all have Triggers have any impact on the games update, bearing in mind I’m aiming at iPhone ultimately?
Yes, Galaga is getting on in years. As someone who was in his mid-teens when Galaxians came out, I’m a big fan of the oldies. I guess Galaxians would be a better game to think of in relation to my game as I’d like to have the side-to-side sheet of aliens.

Bringing me to Q2: Would parenting such a sheet of alien sprites to a central Null-type object, thus moving the aliens by moving the Null, be the best (most efficient) way of moving multiple sprites?
I’m still nervous about these new-fangled methods like parenting and dynamic creation, coming from years of limited hardware sprites and efficient looping code I guess
:?

I couldn’t answer your question in terms of performance on the Iphone. There’s one way to find out though!

I’m also not sure about the best way to determine collisions between pseudo-sprites on planes At first thought, I’d use box colliders for the planes. Triggers are ok, as you don’t need detailed collision information and a rigidbody is fine for your bullets. The aliens themselves don’t need to be rigidbodies.

Perhaps looking around in the Iphone forum would give you some guidance on that. Check out one of the threads on using SpriteManager.

I soon left those space-invader clone games behind, when high technology state of the art games such as Startgate and Defender came out!

That would likely be the perfect way to move then in unison, galaga or space invaders style. When your boss alien wants to attack, simply de-parent him for his dive bomb run. It would also easy the procedural creation of your various formations, as you could simply effect it by an array holding offsets relative to your parent object.

SpaceCadet:

I’ll second the suggestion to check out SpriteManager if you are going to be finishing on the iPhone. The caution I’d throw out there is that you may find that using SpriteManager could be substantially different in it’s approach than using sprite-like objects parented to a new Empty Game Object (your null) in Unity. Moreover, as far as I know, it may only work on the iPhone, which could throw off your development schedule by forcing you to develop that part twice.

If you plan on making a web/stand-alone version before porting it to the iPhone (not a bad idea), put a note in your schedule that there may be more work beyond just adding strong typing to your code. You may discover issues like your OnGUI and GUI.x performing too slowly during the game(which there are solutions on the iPhone forum), and the need to covert to SpriteManager for your enemy objects.

Don’t avoid prototyping in Unity basic. This may help you work out many issues without having to deal with the remote and xCode. If you are using Unity.js as your base language, prototype with the line #pragma stict at the top of all your scripts so your typing is strong enough for the iPhone (and it won’t hurt your desktop game), and add time to your schedule for the port to the iPhone, and then double that time! (~.^)

Thanks for the posts both of you. I have taken a look at Sprite Manager with a view to using it in the future. I’m more of a 3D artist than coder so I have to take it steady or the old brain melts. Can I just ask quickly, when using SM are all the usual collision methods applicable ?
@ Quietus: the part “It would also easy the procedural creation of your various formations, as you could simply effect it by an array holding offsets relative to your parent object.” is interesting as that was going to be a future question for yourself or anyone with an interest in 2d shooters. . I’m hoping to get a single alien sprite to swoop and do loops/patterns a la Galaga but again need to pick a best method. I was thinking that maybe a table could hold the X Y offsets for them but am unsure when/how I should call these and add their offsets during such a ‘dive’ movement.
Would some kind of Timer, assigned to that single sprite, that incremented only during the dive be capable of cycling through the offset values and adding them to the X&Y co ords?
Thanks for any help, they’re the last questions for now
:smile:

I’m not familiar with it, but as they are probably just uv scrolled textures on planes I would imagine so. You’ll have to look further.

Since you’re targeting Iphone, using a trigger and a non-kinematic rigidbody for the bullet would likely be more performant than more detailed collisions. You can get away with using particle effects at the coordinates of the destroyed enemy, instead of where the bullet actually collides, as the screen is so small nobody would notice.

I would use an array of offsets just to setup the initial formation. I would likely chose a different route for his attack. Detaching it from the parent null object and using the Spline Controller on the wiki would be my first thought. Would make it far easily to fiddle with for complex ‘swooping’ operations. Other than that I might try a simplified waypoint following setup. But an array of offsets to animate through figured out by hand? No, making my life a living hell setting those up would not be an option I’d go for.

Drawing a spline in a 3d app, or moving waypoint objects about in the inspector and creating multiple arrays of them would be far easier than typing coordinates in by hand.

using the Spline Controller

That is an interesting idea. I’ll make an effort to get to grips with the Splines, it hadn’t crossed my mind.

Thanks.