Sunday, July 10, 2016

Thursday, June 9, 2016

CODE ballscript

public class ballController : MonoBehaviour
{

public Transform spawnPoint;
public GameObject gameOverText;
public GameObject youWonText;
bool onGround = false;
bool isDead = false;
bool youWon = false;
// Use this for initialization
void Start ()
{
Physics.gravity = Vector3.down * 20;
onGround = false;
isDead = false;
gameOverText.SetActive(false);
}

// Update is called once per frame
void Update ()
{

Vector3 pos = GetComponent<Transform>().position;
pos.y -=0.5f;
Collider[] colliders = Physics.OverlapSphere(pos, 0.01f );
int i=0;
onGround = false;
while (i < colliders.Length)
{

if(colliders[i].gameObject.layer == LayerMask.NameToLayer("Ground"))
{
onGround = true;
}
if(colliders[i].gameObject.layer == LayerMask.NameToLayer("DeadBox"))
{
isDead = true;
GetComponent<Rigidbody>().isKinematic = true;
gameOverText.SetActive(true);
}
i++;
}

if(Input.GetKeyDown(KeyCode.Space) )
{
if (isDead)
{
gameOverText.SetActive(false);
isDead = false;

GetComponent<Transform>().position = spawnPoint.position;
GetComponent<Rigidbody>().isKinematic = false;
}
else if (youWon)
{
youWonText.SetActive(false);
youWon = false;

GetComponent<Transform>().position = spawnPoint.position;
GetComponent<Rigidbody>().isKinematic = false;
}
else if(onGround)
{
GetComponent<Rigidbody>().AddForce(Vector3.up * 500);
onGround = false;
}
}

if(Input.GetKey(KeyCode.RightArrow))
{
GetComponent<Rigidbody>().AddForce(Vector3.right * 10);
}
if(Input.GetKey(KeyCode.LeftArrow))
{
GetComponent<Rigidbody>().AddForce(Vector3.left * 10);
}
}

public void playerWon()
{
youWon = true;
}
}

CODE

public class <YOUR NAME>: MonoBehaviour {
public GameObject ball;
public GameObject youWonText;
// Use this for initialization
void Start () {
youWonText.SetActive(false);

}

void OnTriggerEnter(Collider other)
{
youWonText.SetActive(true);
ball.GetComponent<ballController>().playerWon();
ball.GetComponent<Rigidbody>().isKinematic = true;
}
// Update is called once per frame
void Update () {

}
}

COMPUTER - MATERIAL

Here is the latest Unity project LINK

-Download it and unzip it in drive D
-Open it with Unity.

Also download this star LINK
-You can download it anywhere
-Once downloaded go to the folder its in and drag and drop it in the project tab in Unity.

-Today we will add a goal reward (star/coin) and a you win message.

Thursday, June 2, 2016

CODE FOR UPDATE

if(Input.GetKeyUp(KeyCode.Space))
{
GetComponent<Rigidbody>().AddForce(Vector3.up * 500);
}
if(Input.GetKey(KeyCode.RightArrow))
{
GetComponent<Rigidbody>().AddForce(Vector3.right * 10);
}
if(Input.GetKey(KeyCode.LeftArrow))
{
GetComponent<Rigidbody>().AddForce(Vector3.left * 10);
}

COMPUTER MATERIAL 03 06 2016


Here is a link for the project so far for today's class LINK

Wednesday, June 1, 2016

COMPUTER - Materials Simple ball movement

Here is the link for the unity project, save it in your computer (D drive in school) and open it with Unity.
LINK

Sunday, May 29, 2016

Occupations and Technology Material link

Material

Here is the link for the power-point presentations : LINK

If you think you need a printed version please let me know.