basic project for Unity 5.x workshops.
For more informations contact me @ilwoody
xplode is a classic endless vertical shooter created to demonstrate the power of Unity3D as a fast prototyping tool; no previous knowledge in game programming is required.
http://nferruzzi.github.io/xplode/Builds/webgl/
- Nicola Ferruzzi
- Lorenzo Berni
- Ivan Nikolaev
- Iacopo Marmorini
- Elise Cicognani
the goal of the workshop is building a game from scratch to become familiar with the following concepts:
- the workspace: unity editor, layouts, manipulators, C# debugger and sources revision control for Unity with common tools (ie git)
- GameObject hierarchy, Layers and Tags
- MonoBehaviour and componets (ie. functions Start, Update, GetComponent, public variables)
- Transform and Time classes
- Prefabs and assets management
- Creations and destruction of objects at runtime
- Inspector and serialization of custom class
- Use of gizmos to draw information on screen
- Collisions and rigid bodies
- C# interfaces
- Invoke, InvokeRepeating and coroutines
- Unity editor scripts
- Game UI and scene management
TODO.
The game can be customized in several ways
See BaseEnemy.cs
and Prefab Cubo Nemico
.
- create a GameObject and call it as you wish
- set the Layer to "Enemies"
- add Mesh, Collider, RigidBody
- tweak your RigidBody properties (e. fix Y)
- add
WeaponGun
component if it fires from a single weapon orWeaponController
if it has more than one - on its Start method, get a spawning location from the
Spawner
instance. - schedule it's behaviour according to your own logic
- add method
OnCollisionEnter
void OnCollisionEnter(Collision collision) {
Proiettile pro = collision.gameObject.GetComponentInChildren<Proiettile> ();
if (pro == null) return;
energy -= pro.damage;
foreach (ContactPoint contact in collision.contacts) {
pro.ShowExplosionAt (contact.point, contact.normal);
}
if (energy <= 0.0f) {
Destroy (this.gameObject);
}
}
See WeaponGun.cs
and Prefab PlayerBaseGun
TODO.
See Proiettile.cs
and Prefabs Bullet
or EnemyBullet
TODO.
See LevelRandomGenerator.cs
TODO.
Spawner
It is used to create a boundary of MainCamera
visible area so enemies or the game logic can take it in account.
The boundary is formed by 4 Vector3d
calculated according to the camera frustum, the camera aspect ration and the player "y" coordinate.
The spawning point are stored in 3 arrays
spawnLocationsTop
, spawnLocationsLeft
, spawnLocationsRight
and ca be queried at runtime using
Spawner.GetInstance()
WeaponController
It is used to store multiple weapons and fire them all together.
LevelRandomGenerator
Very simple level generator, it is used to spawn enemeies with a regular frequency.
IWeaponInterface
See WeaponGun.cs
IProjectileInterface
See Proiettile.cs