Skip to content

9월 17일 스터디 한 아이템 먹는것 까지 입니다.

September 23, 2010

CollisionTest.cs (문열리는 닫히는 내용)

using UnityEngine;
using System.Collections;

public class CollisionTest : MonoBehaviour
{
    GameObject doorObject = null;

 // Use this for initialization
 void Start () {
        doorObject = GameObject.Find(“door”);
 
 }
 
 // Update is called once per frame
 void Update () {
 }

    void OnTriggerEnter(Collider collisionInfo)
    {
        doorObject.animation.Blend(“door_open”);
    }

    void OnTriggerStay(Collider collisionInfo)
    {
    }

    void OnTriggerExit(Collider collisionInfo)
    {
        doorObject.animation.Blend(“door_close”);
    }
}

ColliderHitController.cs 소스(아이템 먹는 내용)

using UnityEngine;
using System.Collections;

public class ColliderHitController : MonoBehaviour
{
    static int GRENADE_AMMO = 0;

 // Use this for initialization
 void Start () {
 
 }
 
 // Update is called once per frame
 void Update () {
 
 }

    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.tag == “item”)//아이템이라는 테크 개체를 체크합니다.
        {
            Destroy(hit.gameObject); //게임내에서 사라집니다.
            GRENADE_AMMO += 8; //8개의 아이템을 획득합니다.
            GameObject bombCount = GameObject.Find(“bomb_count”);
            GUIText guiText = bombCount.GetComponent<GUIText>();//화면상에 습득한 아이템 수를 표시합니다.
            guiText.text = “” + GRENADE_AMMO;
            guiText.text = GRENADE_AMMO.ToString();
            print(“YOU NOW HAVE ” + GRENADE_AMMO + ” GRENADES”);
        }

    }

}

 

Copyright from Bgrade offline study.

Advertisements

From → Unity3D Study

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: