Skip to content

nferruzzi/xplode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xplode

basic project for Unity 5.x workshops. For more informations contact me @ilwoody

Abstract

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.

Live link

http://nferruzzi.github.io/xplode/Builds/webgl/

Credits

  • Nicola Ferruzzi
  • Lorenzo Berni
  • Ivan Nikolaev
  • Iacopo Marmorini
  • Elise Cicognani

Main goal

the goal of the workshop is building a game from scratch to become familiar with the following concepts:

1st day

  1. the workspace: unity editor, layouts, manipulators, C# debugger and sources revision control for Unity with common tools (ie git)
  2. GameObject hierarchy, Layers and Tags
  3. MonoBehaviour and componets (ie. functions Start, Update, GetComponent, public variables)
  4. Transform and Time classes
  5. Prefabs and assets management
  6. Creations and destruction of objects at runtime
  7. Inspector and serialization of custom class
  8. Use of gizmos to draw information on screen

2nd day

  1. Collisions and rigid bodies
  2. C# interfaces
  3. Invoke, InvokeRepeating and coroutines
  4. Unity editor scripts
  5. Game UI and scene management

The architecture of an endless shooter

TODO.

How to

The game can be customized in several ways

Add a new enemy

See BaseEnemy.cs and Prefab Cubo Nemico.

  1. create a GameObject and call it as you wish
  2. set the Layer to "Enemies"
  3. add Mesh, Collider, RigidBody
  4. tweak your RigidBody properties (e. fix Y)
  5. add WeaponGun component if it fires from a single weapon or WeaponController if it has more than one
  6. on its Start method, get a spawning location from the Spawner instance.
  7. schedule it's behaviour according to your own logic
  8. 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);
  }
}

Add a new weapon

See WeaponGun.cs and Prefab PlayerBaseGun

TODO.

Add a new bullet

See Proiettile.cs and Prefabs Bullet or EnemyBullet

TODO.

Generate a random level

See LevelRandomGenerator.cs

TODO.

Components

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.

Interfaces

IWeaponInterface

See WeaponGun.cs


IProjectileInterface

See Proiettile.cs

About

Unity workshop

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages