본문 바로가기
반응형

Programing/unity21

유니티,unity,클릭시 다른오브젝트 사라지게 하기 public class Move : MonoBehaviour {// 이 스크립트를 바인딩한 오브젝트를 클릭해야 사라집니다.public GameObject ss; void OnMouseDown(){ ss.SetActive (false);}} a 라는 오브젝트에; 위 스크립트를 바인딩하고, 맨위의 스크립트에서 ss 에 사라지게 만들 오브젝트를 드래그 해서 넣어줍니다.public GameObject ss; 코드처럼 public 을 지정하면 inspactor 창에서 바인딩할 오브젝트 빈칸이 생깁니다. 2017. 2. 24.
유니티,unity,키를 누를때 회전,nput.GetKey,KeyCode,transform.Rotate void Update () {if (Input.GetKey (KeyCode.A)) { // a 키를 누를때transform.Rotate (0.0f, 90.0f*Time.deltaTime, 0.0f);// y축만 90도를 넣고 1초당 움직이게 Time.deltaTime 곱해줍니다. } if (Input.GetKey (KeyCode.D)) {transform.Rotate (0.0f, -90.0f*Time.deltaTime, 0.0f);}} 2017. 2. 24.
unity,유니티,transform.position. z 값 사용,GameObject 선언 public class ballMove : MonoBehaviour {// 적캐릭터에게 바인딩 해줘야 하는 스크립트 입니다.public float speed;public GameObject gm;// 플레이어오브젝트를를 gm 으로 선언하고 ,inspactor 창에서 등록해준다.void Update () {transform.position += Vector3.back * Time.deltaTime * speed;// Vector3.back 반대방향으로 오게 함 if (transform.position.z < gm.transform.position.z ){ // 적이 플레이어 오브젝트를 통과하면 없앤다. Destroy(gameObject); }}} 2017. 2. 23.
유니티,unity,반대로 날아오는 오브젝트,Vector3.back,LookRotation,Instantiate public class ballMove : MonoBehaviour { public float speed;// Use this for initializationvoid Start () {}// Update is called once per framevoid Update () {transform.position += Vector3.back * Time.deltaTime * speed;// Vector3.back 반대방향으로 오게 함}} public class ballCopy : MonoBehaviour { public GameObject ball; Vector3 pos; // Use this for initializationvoid Start () {StartCoroutine(Sleep());} IEnum.. 2017. 2. 23.
반응형