->콜라이더랑 완전히 맞추려면 asset에 콜라이더 mesh정보를 가지고있어서 mesh콜라이더로 하면 완전히 맞출 수 있음(convex도 처리)
->
using UnityEngine; using System.Collections; public class csBullet : MonoBehaviour { public GameObject exp; public float speed = 12.0f; public float power =3; // Use this for initialization void Start () { } void OnTriggerEnter(Collider obj) { if(obj.tag=="enemy") { Destroy (obj.gameObject); } else if(obj.tag =="barrel"){ obj.rigidbody.AddForce(transform.forward*power); } Instantiate(exp,transform.position,transform.rotation); Destroy(this.gameObject); } // Update is called once per frame void Update () { transform.Translate(Vector3.forward*speed*Time.deltaTime); } }
->하위요소로간다는 것은 어떤것의 부모를 설정해주면됨.
->파티클에서 민,맥스 애미션 차이크면 뭉게뭉게..
->setActive가 오브젝트를 껏다켰다..
using UnityEngine; using System.Collections; public class csMove : MonoBehaviour { public GameObject exp; public float speed = 3f; public float rotSpeed = 60; public GameObject smoke; float passtime = 0f; // Use this for initialization void Start () { smoke.SetActive(false); } // Update is called once per frame void Update () { float mv, mh; mv = Input.GetAxis ("Vertical"); mh = Input.GetAxis ("Horizontal"); if(mh!= 0 || mv!=0) { passtime = 0f; smoke.SetActive (true); }else { passtime = passtime +Time.deltaTime; Debug.Log(passtime); if(passtime>2.0f) { smoke.SetActive (false); passtime = 0f; } } transform.Translate(Vector3.forward*mv*speed*Time.deltaTime); transform.Rotate(Vector3.up*mh*rotSpeed*Time.deltaTime); } }
'Unity' 카테고리의 다른 글
Unity3D #9 (0) | 2015.01.15 |
---|---|
Unity3D #8 (0) | 2015.01.14 |
Unity3D #6 (0) | 2015.01.12 |
Unity3D #5 (0) | 2015.01.09 |
Unity3D #4 (0) | 2015.01.08 |