The empty project
The ground – a 3D Plane
Adding in the model, dragging in a maya file into the assets folder.
The asset is now in the assets folder.
Check the inspector settings – I need Normals to be calculated to create a smooth effect on the model (rather than low poly)
Putting the player into the scene. The player seems massive compared to my floor… I also set the position to 0,0,0
Creating an empty gameObject called Player1 and putting the HighPoly Model inside.
Scaling up the floor. Re-naming player so that it is easier to identify.
Creating a c# script by right clicking in the project window.
Calling the script Player.
This script will hold all the player values.
Adding a rigidBody to the player (found under Add Component > Physics). Gravity needs to be turned on.
Also adding a BoxCollider
The box collider is made to fit the character (see green edge)
Adding tiles, I imported a maya tile I had made
I created a prefab and attached the model to it – tile.
I then made lots of tiles
Creating a script called tile.
Creating an Empty GameObject called Enemy
Create a script for the enemy.
Create enemy variables:
I made a Pulse Script to store information on the type of attack the enemy will have.
The pulse has the variables:
I made an Empty Game Object called Players (to keep things tidy) – and put Player1 in the gameObject.
Creating the Hamsas. I made another prefab called Hamsa and attached a model to it, and scaled it slightly.
I then created an empty gameObject called Hamsas and put in a couple of Hamsa prefabs
I then created hamsa script.
With their variables:
I made a colour script to hold all the colours that will be used in the game.
This will use a dictionary – colours
Add some colours to the colour dictionary.
Create a movement script
This has variables:
- vertical Instruction
- horizontal Instruction
Create a collect script.
- Collect Instruction
Attach the movement script to the player, by dragging it onto the gameObject player1.
Add some script to Movement:
Adding some script to Pulse
Add TakeDamage to the player script – so that the Pulse script is talking to something.
Add some more player (so that there are four). I just copy and pasted the player I had already made.
- I will need to change the controllers for each of these players at some point
Add the Hamsa script to the hamasa. Or add to one and then click Apply (in the prefab bit) to change all of them.
In the pulse attack, need to add Hamsa’s to the list of things to remove health from.
Need to give the hamsa’s health and a TakeDamage function.
Create a delegate in the Hamsa script, to handle sending the damage information to the Hamsa’s and players. This replaces the Send.Message functionality with a nicer piece of code.
- public delegate PulseDamage
- public static event PulseDamage with a function called timeUp
Add the other part of the delegate to the Hamsa and Player information.
You need a:
- Name of the function that runs because pulse.timeUp has happened – TakeDamage.
Note// This uses the same code – is it worth having a manager for these two things – so that code is not replicated?
Further reading on delegates and events