VideoGameWeezy
Tuesday, September 8, 2015
Video Game design Video 14 and 15
Videos 14 and 15 do not require any code. Have fun and pay attention.
Friday, September 4, 2015
videos 12, 13!
I was unfortunately sick last night and didn't feel like taking step by step notes but I did write the scripts down that I used so that you can, AT THE END OF THE VIDEOS, check the script. Please Please Please DO NOT copy and paste the script. Please follow along with the videos and listen very carefully to the descriptions from the video!
video 12:
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
var Hit01 : AudioClip;
var Hit02 : AudioClip;
var Hit03 : AudioClip;
var distToGround : float;
function Start () {
// Getting the distance from the center to the ground.
distToGround = collider.bounds.extents.y;
}
function Update ()
{
//Handle ball rotation.
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode.W) && IsGrounded ())
{
rigidbody.velocity.y = jumpHeight;
}
}
function IsGrounded () : boolean { //Check if we are on the ground. Return true if we are else return null.
return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1);
}
function OnCollisionEnter () {
var theHit = Random.Range(0, 3);
if (theHit == 0)
{
audio.clip = Hit01;
}
else if (theHit == 1)
{
audio.clip = Hit02;
}
else {
audio.clip = Hit03;
}
audio.pitch = Random.Range (0.9,1.1);
audio.Play();
}
video 13:
#pragma strict
static var currentScore : int = 0;
var offsetY : float = 40;
var sizeX : float = 100;
var sizeY : float = 40;
var musicPrefab : Transform;
function Start () {
currentScore = 0;
if (!GameObject.FindGameObjectWithTag("MM")) {
var mManager = Instantiate (musicPrefab, transform.position, Quaternion.identity);
mManager.name = musicPrefab.name;
DontDestroyOnLoad (mManager);
}
}
function OnGUI () {
GUI.Box (new Rect (Screen.width/2-sizeX/2, offsetY, sizeX, sizeY), "Score: " + currentScore);
}
video 12:
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
var Hit01 : AudioClip;
var Hit02 : AudioClip;
var Hit03 : AudioClip;
var distToGround : float;
function Start () {
// Getting the distance from the center to the ground.
distToGround = collider.bounds.extents.y;
}
function Update ()
{
//Handle ball rotation.
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode.W) && IsGrounded ())
{
rigidbody.velocity.y = jumpHeight;
}
}
function IsGrounded () : boolean { //Check if we are on the ground. Return true if we are else return null.
return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1);
}
function OnCollisionEnter () {
var theHit = Random.Range(0, 3);
if (theHit == 0)
{
audio.clip = Hit01;
}
else if (theHit == 1)
{
audio.clip = Hit02;
}
else {
audio.clip = Hit03;
}
audio.pitch = Random.Range (0.9,1.1);
audio.Play();
}
video 13:
#pragma strict
static var currentScore : int = 0;
var offsetY : float = 40;
var sizeX : float = 100;
var sizeY : float = 40;
var musicPrefab : Transform;
function Start () {
currentScore = 0;
if (!GameObject.FindGameObjectWithTag("MM")) {
var mManager = Instantiate (musicPrefab, transform.position, Quaternion.identity);
mManager.name = musicPrefab.name;
DontDestroyOnLoad (mManager);
}
}
function OnGUI () {
GUI.Box (new Rect (Screen.width/2-sizeX/2, offsetY, sizeX, sizeY), "Score: " + currentScore);
}
Tuesday, September 1, 2015
videos 10 & 11
1. go to gameObject and Create Empty and name it _GM.
2. Add New Component Script and name it GameMaster and open it up in MonoD.
3. On line three add:
static var currentScore : int - 0;
4. Line 5:
function OnGUI () {
5. Move line 5 to line 7 and on line 5 add:
function Update () {
6. On Line 4 add:
var test = 0;
(before he does this, the Brackeys guy sends all of the lines below line 4 on down a line by pressing enter.)
7. On Line 7 add:
test = currentScore;
8. Select the coin and double click the CoinPickup script to open it up.
9. Delete the debug.log on line 9 and add:
GameMaster.currentScore += coinValue;
10. On line 4 add:
var coinValue =1;
11. At about 7 minutes he deletes some lines of code in the GameMaster code.
12. On line 6 add:
GUI.Box (new Rect (screen.width/2-sizeX/2, offsetY, sizeX, sizeY), "score: " + currentScore);
13. On line 5 add:
var offsetY : float - 40;
14. On line 6 add:
var sizcX : float - 100;
15. On line 7 add:
var sizeY : float = 40;
16. In the Inspector window with the GameMaster script selected, change the offset Y to: 40, the size X to 80 and the size Y to 25.
Video 11!!! Almost Finished adding audio.........
1. Double click the GameMaster script and on line 9 add:
function Start {} {
line 10:
currentScore = 0;
}
We do not have any audio, I am not going to tell you to download this music but I want you to watch this video because you will be adding music to your games in the future. You may also download music or sound from home and email it to yourself to use. I'm not taking any notes for this but I want you to watch this because it is very cool.
2. Add New Component Script and name it GameMaster and open it up in MonoD.
3. On line three add:
static var currentScore : int - 0;
4. Line 5:
function OnGUI () {
5. Move line 5 to line 7 and on line 5 add:
function Update () {
6. On Line 4 add:
var test = 0;
(before he does this, the Brackeys guy sends all of the lines below line 4 on down a line by pressing enter.)
7. On Line 7 add:
test = currentScore;
8. Select the coin and double click the CoinPickup script to open it up.
9. Delete the debug.log on line 9 and add:
GameMaster.currentScore += coinValue;
10. On line 4 add:
var coinValue =1;
11. At about 7 minutes he deletes some lines of code in the GameMaster code.
12. On line 6 add:
GUI.Box (new Rect (screen.width/2-sizeX/2, offsetY, sizeX, sizeY), "score: " + currentScore);
13. On line 5 add:
var offsetY : float - 40;
14. On line 6 add:
var sizcX : float - 100;
15. On line 7 add:
var sizeY : float = 40;
16. In the Inspector window with the GameMaster script selected, change the offset Y to: 40, the size X to 80 and the size Y to 25.
Video 11!!! Almost Finished adding audio.........
1. Double click the GameMaster script and on line 9 add:
function Start {} {
line 10:
currentScore = 0;
}
We do not have any audio, I am not going to tell you to download this music but I want you to watch this video because you will be adding music to your games in the future. You may also download music or sound from home and email it to yourself to use. I'm not taking any notes for this but I want you to watch this because it is very cool.
Sunday, August 30, 2015
Video 8 and 9 aka Chu is the man! : Animation
Video 8: You know where to find the video. I haven't used any smiley faces yet, so 8).
You will be creating an naimation inside of unity, very easy.
1. Create a materials folder in the assets window and move all of your scene's materials into that folder.
2. Double the rotationSpeed of the ball to 200. It will be more fun to control!! Woohoo!
3. Select the coin, click on the Add Component button > Miscellaneous > Animation.
4. Press ctrl+6 to open up the animation panel.
5. Press the red record button and name the animation coinRotate.
6. If you are familiar with animating in Flash, After Effects or 3ds Max then the rest of this video is self explanatory. I am not going to type out the steos for this because it would be way too much. If you don't know key frames then keep watching the video, I promise it is very easy.
Video 9
Making Particles for your Coin AKA Chu is still claiming the title of The Man.
1. Go to the Game Object tab > Create Other > Particle System.
2. Change the duration of the particle system to 0.2.
3. The changes to the particle I'm going to let you listen to him and make your own changes. This is really all preferential. I will pick up with the coding. But pay attention and make changes when the video does because you more than likely will want to use this particle system in the future in many different ways.
4. Select the coin and open up the CoinPickup script.
I want you to follow along and listen to everything that the video says, DO NOT skip ahead and just copy and paste my code into your script because this WILL NOT help you at all. But if you end up having issues, here is the code:
Remember to go back and check the case sensitivity and spelling of all of your code.
line 1: #pragma strict
line 3: var coinEffect : Transform;
line 5: function OnTriggerEnter (info : Collider)
line 6: {
line 7: if (info.tag == "Player")
line 8: {
line 9: Debug.log("Add coin counter here!");
line10: var effect = instantiate(coinEffect, transform.position, transform.rotation);
line11: Destroy(effect.gameObject, 3);
line12: Destroy(gameObject);
line13: }
line14: }
You will be creating an naimation inside of unity, very easy.
1. Create a materials folder in the assets window and move all of your scene's materials into that folder.
2. Double the rotationSpeed of the ball to 200. It will be more fun to control!! Woohoo!
3. Select the coin, click on the Add Component button > Miscellaneous > Animation.
4. Press ctrl+6 to open up the animation panel.
5. Press the red record button and name the animation coinRotate.
6. If you are familiar with animating in Flash, After Effects or 3ds Max then the rest of this video is self explanatory. I am not going to type out the steos for this because it would be way too much. If you don't know key frames then keep watching the video, I promise it is very easy.
Video 9
Making Particles for your Coin AKA Chu is still claiming the title of The Man.
1. Go to the Game Object tab > Create Other > Particle System.
2. Change the duration of the particle system to 0.2.
3. The changes to the particle I'm going to let you listen to him and make your own changes. This is really all preferential. I will pick up with the coding. But pay attention and make changes when the video does because you more than likely will want to use this particle system in the future in many different ways.
4. Select the coin and open up the CoinPickup script.
I want you to follow along and listen to everything that the video says, DO NOT skip ahead and just copy and paste my code into your script because this WILL NOT help you at all. But if you end up having issues, here is the code:
Remember to go back and check the case sensitivity and spelling of all of your code.
line 1: #pragma strict
line 3: var coinEffect : Transform;
line 5: function OnTriggerEnter (info : Collider)
line 6: {
line 7: if (info.tag == "Player")
line 8: {
line 9: Debug.log("Add coin counter here!");
line10: var effect = instantiate(coinEffect, transform.position, transform.rotation);
line11: Destroy(effect.gameObject, 3);
line12: Destroy(gameObject);
line13: }
line14: }
Video 3a.
video 3a. link:
https://www.youtube.com/watch?v=PazLGgeFkHI
Remember to watch the videos and listen carefully. Don't copy and paste what I have written, just use my notes as a guideline.
1. In mono Develop underneath var rotationSpeed = 100
add:
var jumpHeight = 8;
2. on line 6 add:
private var isFalling = false;
3. move everything from line 10 down a line by pressing enter at the beginning of the line. Now add this to line 10:
//handle ball rotation.
4. On line 15 add:
if (Input.GetKeyDown (KeyCode.W))
{
rigidbody.velocity.y = jumpHeight;
}
5. On line 21 add:
function OnCollisionStay ()
{
isFalling = false;
}
6. Change line 15 to:
if (Input.GetKeyDown (KeyCode.W) && isFalling == false)
7. Pay attention to this part of the video and on line 19 add:
isFalling = true;
Video 3b. link:
https://www.youtube.com/watch?v=m8VPHAs0F8w
1.
https://www.youtube.com/watch?v=PazLGgeFkHI
Remember to watch the videos and listen carefully. Don't copy and paste what I have written, just use my notes as a guideline.
1. In mono Develop underneath var rotationSpeed = 100
add:
var jumpHeight = 8;
2. on line 6 add:
private var isFalling = false;
3. move everything from line 10 down a line by pressing enter at the beginning of the line. Now add this to line 10:
//handle ball rotation.
4. On line 15 add:
if (Input.GetKeyDown (KeyCode.W))
{
rigidbody.velocity.y = jumpHeight;
}
5. On line 21 add:
function OnCollisionStay ()
{
isFalling = false;
}
6. Change line 15 to:
if (Input.GetKeyDown (KeyCode.W) && isFalling == false)
7. Pay attention to this part of the video and on line 19 add:
isFalling = true;
Video 3b. link:
https://www.youtube.com/watch?v=m8VPHAs0F8w
1.
Tuesday, August 18, 2015
Making a Ball Jump in Unity
Ask me for the Unity license if it is not written up on the board.
**Bring your earbuds to class everyday***
The video links are at the bottom of this page, they must be copied and pasted.
2. Click the Create button.
3. In the scene window, press ALT and the left mouse button and drag your mouse around. This is how you orbit or pan around the scene.
4. By Pressing ALT + CTRL and left clicking and dragging you can drag the scene left to right.
5. By scrolling the wheel on your mouse you will zoom in and out.
6.In the upper right hand corner of the scene window is the Orbit Gizmo that you can click on for a perspective view, an isometric, left, front, top and bottom views of the scene. You can also click on this if you ever zoom out too far in the scene and get lost.
7. Go to the GAmeObject tab at the top of the screen and Create Other and choose the cube. at 7:47 on the youtube video timeline you will "zero out" the cube. This mean that you will change the X,Y,Z coordinates of the cube to X=0, Y=0, Z=0 OR 0,0,0. This is the center of the scene.
8.By pressing the F key on the keyboard you will focus on, or zoom in on the object in the scene that you have selected.
9. Go to the Inspector Window View and change the scale of the XYZ to 10,1,1.
10. Go to the top tap titled GameObject and add a sphere.
11. Zero out the position of the sphere. By clicking and dragging on the Green Y axis arrow that is on the sphere, drag the sphere above the box,
12. Go to the Hierarchy window and rename that objects. By right clicking on the name of the object you can rename it. Change the sphere to Ball. Change the cube to Ground. Rename the main camera to MainCamera without a space.
13. Go to the GameObject tab and Create Other and add a point light.
14. Change the position of the light to X=0 Y=4 Z= -1. Look for the range section of the light directly below the position coordinates and change that to 10.
11. Change the name of the light to Light01.
Part 2:
1. First select the sphere and go to the Inspector window click the AddComponent button and add a Rigid Body.
2. With the sphere still selected click on the AddComponent button and select New Script and name it BallControl. Change the language to JavaScript. Next click the Create and Add button.
3. Now double click the script to open it in Mono Develop.
4. Inside the Function Update type:
{
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
}
5. Above the function update create the rotationSpeed variable by typing:
var rotationSpeed = 100;
6. Below the var roatation line of code type:
rotation *= Time.deltaTime;
rigidbody.AddRelativeTorque (Vector3.back * rotation);
7. By pressing the play button, you should be able to move the ball left to right using the A and the D keys on the keyboard.
I would like to use this as a good place to stop until next class so everyone has the chance to catch up and stay on the same page.
here is the first video link that I used from Youtube.
:
https://www.youtube.com/watch?v=g5QFW12utdU
here is the second video:
Subscribe to:
Comments (Atom)