Skip to content

Instantly share code, notes, and snippets.

@kaibadash
Created December 10, 2017 08:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kaibadash/fdf576d91d06426e75f460473c1439ce to your computer and use it in GitHub Desktop.
Save kaibadash/fdf576d91d06426e75f460473c1439ce to your computer and use it in GitHub Desktop.
unity tutorial
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MinoDetecter : MonoBehaviour {
void Start () {
}
void Update () {
}
private void OnCollisionEnter(Collision other) {
Debug.Log(other.gameObject.tag);
if (other.gameObject.tag == this.tag) {
return;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MinoMover : MonoBehaviour {
void Start () {
}
void Update () {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
this.transform.localPosition = new Vector3(
this.transform.localPosition.x,
this.transform.localPosition.y,
this.transform.localPosition.z + 1.0f
);
}
if (Input.GetKeyDown(KeyCode.DownArrow)) {
this.transform.localPosition = new Vector3(
this.transform.localPosition.x,
this.transform.localPosition.y,
this.transform.localPosition.z - 1.0f
);
}
if (Input.GetKeyDown(KeyCode.LeftArrow)) {
this.transform.localPosition = new Vector3(
this.transform.localPosition.x - 1.0f,
this.transform.localPosition.y,
this.transform.localPosition.z
);
}
if (Input.GetKeyDown(KeyCode.RightArrow)) {
this.transform.localPosition = new Vector3(
this.transform.localPosition.x + 1.0f,
this.transform.localPosition.y,
this.transform.localPosition.z
);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour {
public GameObject prefabMinoB;
public GameObject prefabMinoC;
public GameObject prefabMinoL;
public GameObject prefabMinoT;
public GameObject prefabMinoZ;
private List<GameObject> prefabList;
void Start () {
prefabList = new List<GameObject>() {
prefabMinoB, prefabMinoC, prefabMinoL, prefabMinoT, prefabMinoZ
};
this.StartCoroutine(this.Spawn());
}
void Update () {
}
private IEnumerator Spawn() {
Instantiate(prefabList[Random.Range(0, prefabList.Count)], this.transform);
yield return new WaitForSeconds(3.0f);
this.StartCoroutine(this.Spawn());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment