Now create a new script, the reason for this is to create a script that will destroy the asteroid explosions since they are permanent since they cant be destroyed by boundary or trigger, name the script DestroyByTime Public class DestroyByTime : MonoBehaviour { Public float lifetime; Void Start () { Destory (gameObject, lifetime); } } Back in unity prefabs VFX explosions select the explosion asteroid, add component, scripts and select DestroyByTime then set the lifetime to 2, do the same for the remaining explosion prefabs this means that the explosions are no longer crowding the scene which will have an impact on performance should things get out of hand, this code helps keep it in order. Audio is a large part of video games especially when it comes to immersion and can make a game, of course I can’t make the audio from scratch but using unity store assets I picked a few pieces of audio to use in this project. Select the explosion asteroid prefab so that ...
Posts
- Get link
- X
- Other Apps
Now to create a game controller start by making a new game object and name it Game Controller and set it to origin position and change the tag to Game Controller and add component, new script and name it game controller, now edit the game controller script. Public class GameController : MonoBehaviour { Public GameObject hazard; Public Vector3 spawnValues; Public inthazardCount; Public float spawnWait; Public float startWait; Void start () { StartCoroutine (SpawnWaves ()); } IEnumerator SpawnWaves () { Yield return new WaitForSeconds (startWait); while (true) { For (int I = 0; i < hazardCount; i++) { Vector3 spawnPosition = new vector3 (Random.Range (-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z); Quaternion spawnRotation = Quaternion.identity; Instantiate (hazard, spawnPosition. spawnRotation); Yield return new WaitForSeconds (spawnWait); } Yield return new WaitForSeconds (waveWait); } } } Select the Game Contr...
- Get link
- X
- Other Apps
Now that the script is set up we can remove the Mesh Renderer and Cube (Mesh Filter) components. I decided to add some space debris to keep things interesting as well as boost score, to do this add new game object and rename it to Asteroid and set the transform Z-axis to 8. Taking an asteroid model from the models folder drag it to the Asteroid parent object in the hierarchy making the asteroid model a child. Select the Asteroid parent and add component physics, rigidbody and deselect use gravity then add another component physics, capsule collider then alter the collider to match the rough size of the asteroid. With the asteroid game object selected add component, new script and rename it to RandomRotator. Open this script and edit it Public class RandomRotator : MonoBehaviour { Public float tumble; Void start () { GetComponent<rigidbody>().angualrVelocity = Random.insideUnitSphere * tumble; } } Select the Asteroid parent and set the tumble value to 5 an...
- Get link
- X
- Other Apps
Create a new empty game object and rename it to Bolt and reset its transform then create a quad and name it VFX and reset its transform as well them add it as a child of bolt. Change the transform rotation X-axis of VFX to 90, to rotate it upwards to the camera. Now we need an image for the bolt, in the materials folder create material which makes a new material in the materials folder and rename it to fx_bolt_orange. Next drag the texture onto the newly created material to apply that texture to it. Now drag the material onto the quad. Once again, we need to change the shader of the material to particles, additive. Now select the Bolt parent and add component, physics, rigidbody and deselect use gravity, reselect VFX and remove the mesh collider component then back to the Bolt parent and add component physics, capsule collider. Change the direction to Z-axis then resize the collider via the radius and height to match the Bolts size and select the Is Trigger box. Still in the Bolt par...
- Get link
- X
- Other Apps
Create a new folder in assets and name it Scripts, Then click on the player in the hierachy and add component scripts, new script. and name it PlayerController, then drag and drop the script into the Scripts folder and open it up in monoDevelop. Remove the sample code. [System.Serializable] public class Boundary { public float xMin, xMax, zMin, zMax; } public class PlayerController : MonoBehaviour { public float speed; public float tilt; public Boundary boundary; void FixedUpdate () { float moveHorizontal = Input.GetAxis ("Horizontal"); float moveVertical = Input.GetAxis ("Vertical"); Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical); GetComponent<rigidbody>().velocity = movement * speed; rigidbody.position = new Vector3 ( Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax), 0.0f, Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax), ); ...
- Get link
- X
- Other Apps
Now to add a background that is not just a black void, which while space is it is not very interesting for a game world. Click on the player in the hierachy and deselect or uncheck the box next to the player in the inspector just so that it is not in the way. Then create 3D object, quad and rename it to Background, using the scene view so that it is visable and reset its transform and set its rotation X-axis to 90 this will make it visible in the game view though it is not necessary to use that view at the moment stick with scene view and remove the quads mesh collider component as it is not required. now it needs a texture, now to scale up the quad by changing the scale X-axis to 21 and Y-axis to 21 so that it fits into the game view nicely, if you were using a texture with an image resolution of 1024x2048 you would want to have the scale X be half of the Y-axis so an example would be X 15 and Y 30 to make sure the image does not become blurry. Next to add some lighting to the bac...
- Get link
- X
- Other Apps
Now for my most enjoyable part, setting up the camera. Start by selecting the Main Camera in the hierarchy and resetting its transform in the inspector, we do this because we want the view point of the player to be top-down so having it in the origin point helps this process. Then rotate the X-axis to 90 degrees, next in take the Y-axis of position and set it to 10 and this should give you a decent view. Now for the camera component, change the projection from Perspective to Orthographic and using the Game view and set the size to 10 then to make sure the ship is not in the center view of the camera change the camera position along the Z-axis to 6 and then change the Clear Flags to solid color i then set the background color to black so that there will be some cinematic arcade black borders. Next select create, light, directional light and rename it Main Light and reset its position so its at the origin point, then reset its rotation to 0 then set the X-axis to around 20. Then chang...
- Get link
- X
- Other Apps
Some of the assets i downloaded were some visual effects or VFX, i use these to make it so there is a stream of fire coming from the engine area of the player ship to make it look like its actually running which helps immersion. Do this by locating the engines_player prefab and drag it onto the Player ship in the hierachy tab so that it is added as a child game object, the prefab is made up of two particle systems.
- Get link
- X
- Other Apps
Since im basically working from scratch at this point chances are i wont have time to make all my own assets so ill be using a lot of them from the unity asset store and will hopefully have time to change them for my own at a later date, not that having placeholders is a bad thing mind you. using the scene view drag the players ship model from the model folder into the scene view i then named it Player. After that using the inspector and looking at the transform tab make sure that the position and rotation is set to 0 to so that it is in the center. next add component and add physics then rigid body and deselect gravity since its going to be in space. I then needed to add a colider which is done much the same as the rigid-body by using the add component option, physics, capsule collider which puts a sphere-like shape around the player ship, then i changed the capsule colliders size by changing its direction to the z-axis and reducing the radius and increasing its height so it resembles...
- Get link
- X
- Other Apps
The spitfire all in all turned out rather well, although the texturing could use a fair bit of work but i did make a small clip of it taking off and retracting its landing gear. However after getting it to a point i was happy with it and thinking about the game i was making and that i was still struggling with camera issues and visual effects such as the flash when firing a though crossed my mind why not instead of trying and struggling to make this isometric zombie horde type game that i could instead make a top down shmup or shoot em up like Asteroids or space invaders but without the cover/destructible bunkers and more movement.
- Get link
- X
- Other Apps
Spent the past week making various vehicles such as tanks and even a boat then a thought came to me, since i have already made a windmill and did some animation for its rotation why not make a aircraft. So i went to google looking for some reasonable image planes that i could use as reference to create the base shape of the aircraft. After searching for a while i came across two image planes for a spitfire, one from the side and the other top down which would allow me to get a decent idea as to the scale of various parts such as the wings in comparison to the size of the fuselage.
- Get link
- X
- Other Apps
Been struggling to create a model that can be used for the player model as well as the models for the enemies as well as how id have to animate them when implementing them into the game as such i decided to put the old western theme to the side and decided to make a vehicle that could be used as the either the player or enemies if not both just with recolors.
- Get link
- X
- Other Apps
After spending the past couple of weeks struggling to fix the camera issues of it clipping through the floor and being far to close to the player character so much so that it also clips through said character I have decided to move on to working on the potentially final models for the character, enemies and level design and come back to the camera issues at a later date.
- Get link
- X
- Other Apps
Having a working HUD is nice seeing the health bar move when taking damage and putting in multiple hits to enemies before they fall to the ground lifeless being shoved out the way by the rest of the horde of cube bots and having the cube bots find the shortest way around objects towards the player and having the small effects of light flashes going off when shooting at them is enjoyable and would certainly add to the experience if it was polished. Unfortunately, there’s problems with the camera positioning which in future versions or attempts I would like to fix so that it is no longer so close to the character and large that it clips through the bottom of the environment and the player but should be achievable with a few minor tweaks in the unity editor with the positioning. I would also like to add sound effects to the game in future such as background music and gun sounds when shooting maybe even some sounds when taking damage and on death would possible. Of course, I would like to ...
- Get link
- X
- Other Apps
Then with the player selected in the hierarchy look at the apply button if we click on the apply button what that will do is if we have a prefab the changes we have made to the objects or scripts will update to the prefabs. Now to move onto spawning enemies to start with go to the hierarchy and create empty object and name it enemymanager then create a script name Enemymanager and drag it onto the EnemyManager in the hierarchy now create another empty in the hierarchy and rename it CubeBotSpawnPoint and position it in the scene view to wherever you want the enemies to spawn from. So now if you click on the EnemyManager in the hierarchy you will see some boxes with None in which we don’t want so click and drag the player from the hierarchy onto the player health property in the EnemyManager which will link it to the player health script so that enemies only spawn while the player is alive then there’s another section for enemies so take a cubebot or enemy from either the ...
- Get link
- X
- Other Apps
We then want to make sure the enemy can attack the player so what we do is make a new script named EnemyAttack and drag it onto the enemy named Cubebot as well as making sure the player can harm the enemies or Cubebots to do this create another script named Enemyhealth and drag it onto the enemy or Cubebot to apply the script. Then to make sure that the gun fires in a line I attached a 3D cube that I scaled down to use as a gun and added a particle system component to the cube gun, I then added another component called line renderer which does as it names suggests renders a line expand the materials tab via the dropdown and click on the circle select via the element 0 and is ideal to use a basic line render material which can be gotten from the asset store or other sources, we then want to expand parameters and set start width and end width to 0.05 then disable the line render check box at the top. Now add a new component by going into rendering and selecting light this i...
- Get link
- X
- Other Apps
Now to implement player health that interacts with the UI to do this create a C# script in the script folder then drag the script onto the player in the hierarchy, in the components section of the player in the player health section you will see Health slider and damage image with None in the boxes next to them you need to click on the health slider in the hierarchy and drag it onto the box with none which will link the health slider component with the player health script do the same with the damage image box below by dragging the damage image from the hierarchy into the damage image none box to link it.
- Get link
- X
- Other Apps
Next will be creating the HUD so to start there’s a 2D button located at the top of the scene view which if you click on will change the view to that of 2D which is helpful for setting up the HUD. So, what we want to do is create a canvas which can be done by going the game object tab mouse over UI and clicking on canvas which will then place a canvas in the hierarchy after which rename it from canvas to HUDCanvas (heads up display). Then add a component called Canvas group which allows UI elements to have an alpha and whether their interactable, then uncheck the Block raycasts box. Then right click on HUDCanvas in the hierarchy tab and click create empty which will create a child and rename the gameobject to HealthUI, the benefits to doing it this way instead of creating an empty then linking it to the HUDCanvas is that if you create the child directly unity knows that your trying to add a new HUD element and gives it the rect transform instead of the normal transform. Now to m...