Unity2014. 8. 5. 15:23

using UnityEngine;

using System.Collections;


public class PlayerController : MonoBehaviour {


public float moveSpeed = 100f;

private int count;


// Use this for initialization

void Start () {

count = 0;

}

// Update is called once per frame

void FixedUpdate () {

float h = Input.GetAxis ("Horizontal");

float v = Input.GetAxis ("Vertical");


rigidbody.AddForce (new Vector3 (h, 0f, v) * moveSpeed * Time.deltaTime);

}

void OnTriggerEnter(Collider other) {


if(other.gameObject.tag == "Item")

{

//Box Collider 인스펙터에서 Is Trigger 체크해서 활성화!

other.gameObject.SetActive(false);


count += 1;

//Destroy(other.gameObject);

}


//Destroy(other.gameObject);

}

}

'Unity' 카테고리의 다른 글

오브젝트를 3개 이상 먹으면 Game Over 처리  (0) 2014.08.05
GUI Text 는  (0) 2014.08.05
카메라가 캐릭터 따라감, 위치 고정. rigidbody  (0) 2014.08.05
오브젝트 별 특성  (0) 2014.08.05
쉐이더  (0) 2014.08.04
Posted by 코드버무려