Created
December 10, 2017 08:27
-
-
Save kaibadash/fdf576d91d06426e75f460473c1439ce to your computer and use it in GitHub Desktop.
unity tutorial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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