Skip to content

Instantly share code, notes, and snippets.

@sabotai
Last active February 8, 2017 22:51
Show Gist options
  • Save sabotai/13d4375a6c604a18ae9fcbf2a49d58e2 to your computer and use it in GitHub Desktop.
Save sabotai/13d4375a6c604a18ae9fcbf2a49d58e2 to your computer and use it in GitHub Desktop.
using UnityEngine;
using System.Collections;
public class BasicConditionals : MonoBehaviour {
//make new public bool and GameObjects
//remember that public means they can be edited in the Unity editor and by other scripts
public bool goToWork;
public GameObject mover;
// Use this for initialization, similar to void setup() in Processing
void Start () {
}
// Update is called once per frame, similar to void draw() in Processing
void Update () {
Debug.Log("game object is at ... " + mover.transform.position);
//check if the GetKeyDown function of Input returns true for "space" (the space bar)
if (Input.GetKeyDown("space")){
//if true ... move the position of mover by (0,1,0)
mover.transform.position += new Vector3(0,1,0);
}
//check it the mover's position is equal to (0,5,0)
if (mover.transform.position == new Vector3(0,5,0)){
//if it is, add on this additional position (5,-5,0)
mover.transform.position += new Vector3(5,-5,0);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment