Unity2015. 1. 14. 15:28

->회전하는 것들은 독립적으로 있어야함

->Mesh Renderer 체크해제하면 안보임

->Debug.DrawRay(Debug.DrawRay(transform.position, transform.forward*20,Color.red);

:transform.position ~ transform.forward까지 선을그어줌

->콜라이더 두개줄수있으니까 따로줘도될거같음...

->transform.looktAt~ 이거 쫌살펴보기..

'Unity' 카테고리의 다른 글

Unity3D #10  (0) 2015.01.16
Unity3D #9  (0) 2015.01.15
Unity3D #7  (0) 2015.01.13
Unity3D #6  (0) 2015.01.12
Unity3D #5  (0) 2015.01.09
Posted by Computer Engineering My Own
Unity2015. 1. 13. 13:54

->콜라이더랑 완전히 맞추려면 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
Posted by Computer Engineering My Own
Unity2015. 1. 12. 14:37

->Distroy(this.gameObjec//소스에서 자기 자신을 죽이는 명령어 

->총알같이 미리 만들어줘야하는걸 prefab이라 함

->하이러키에서 오브젝트로 들고오면 하이러키글자가 파란색으로 바뀌면서 원본이 오브젝트뷰에잇느거임

->스폰포인트라고 발사되는 지점에 작은큐브를생성

->글로벌, 로컬 (회전, 축, 좌표등 다 신경써서해야 제대로 날아감)

->

using UnityEngine;
using System.Collections;

public class csSpPoint : MonoBehaviour {
	public GameObject bullet;
	// Use this for initialization
	void Start () {
		Instantiate(bullet,transform.position,transform.rotation);
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetButtonDown ("Fire1"))//left mouse button
		{
			Instantiate(bullet,transform.position,transform.rotation);
		}
	}
}

Input.GetKeyDown는 파라미터가 KeyCode, string 을통해서 일반적인 키보드 입력을 

받는거고요. 

Input.getButtonDown 에는 KeyCode가 아니라 buttonName으로 작동하는데요. 

buttonName은 Edit->Project Settings->Input 클릭해보시면 세팅할 수 있어요. >

->적같은경우는 prefab으로 하되, 이름보다는 태그로 구분

->


using UnityEngine;
using System.Collections;

public class csBullet : MonoBehaviour {

	public GameObject exp;

	// Use this for initialization
	void Start () {
	}
	void OnTriggerEnter(Collider obj)
	{
		if(obj.tag=="enemy")
		{
			Destroy (obj.gameObject);

		}
		Instantiate(exp,transform.position,transform.rotation);
		Destroy(this.gameObject);
	}
	// Update is called once per frame
	void Update () {
		float speed = 12.0f;
		transform.Translate(Vector3.forward*speed*Time.deltaTime);
	}
}



'Unity' 카테고리의 다른 글

Unity3D #8  (0) 2015.01.14
Unity3D #7  (0) 2015.01.13
Unity3D #5  (0) 2015.01.09
Unity3D #4  (0) 2015.01.08
Unity3D #3  (0) 2015.01.07
Posted by Computer Engineering My Own