Ln Go

Item 본문

Unity/Quad Action

Item

Ln Ro 2021. 6. 4. 02:23
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Item : MonoBehaviour
{
    public enum Type { Ammo, Coin, Grenade, Heart, Weapon };
    public Type type;
    public int value;

    Rigidbody rigid;
    SphereCollider sphereCollider;

    private void Awake()
    {
        rigid = GetComponent<Rigidbody>();
        sphereCollider = GetComponent<SphereCollider>();
    }

    void Update()
    {
        transform.Rotate(Vector3.up * 20 * Time.deltaTime);
        //Item Rotation Code
    }

    private void OnCollisionEnter(Collision collision)
    {
        //GetComponent()는 첫번째 컴포넌트를 가져옴.
        if(collision.gameObject.tag == "Floor")
        {
            rigid.isKinematic = true;
            sphereCollider.enabled = false;
        }
    }
}

'Unity > Quad Action' 카테고리의 다른 글

Shop  (0) 2021.06.04
Follow  (0) 2021.06.04
StartZone  (0) 2021.06.04
Orbit  (0) 2021.06.04
Missile  (0) 2021.06.04
Comments