using UnityEngine;

using System.Collections;


public class Bullet : MonoBehaviour {


// Use this for initialization

void Start () {

rigidbody.AddForce(Vector3.forward * 1000.0f);

}

}


'유니티3D > 예제' 카테고리의 다른 글

miniMap  (0) 2013.08.07
PlayerCtrl  (0) 2013.08.06
MyGizmo.cs  (0) 2013.08.06
Spark.cs  (0) 2013.08.06
bulletCtrl  (0) 2013.07.25

using UnityEngine;

using System.Collections;


public class MyGizmo : MonoBehaviour {

public Color _color = Color.yellow;

public float _radius = 0.2f;

void OnDrawGizmos()

{

Gizmos.color = _color;

Gizmos.DrawSphere(transform.position,_radius);   //DrawSphere --> 

}


}


'유니티3D > 예제' 카테고리의 다른 글

PlayerCtrl  (0) 2013.08.06
Bullet  (0) 2013.08.06
Spark.cs  (0) 2013.08.06
bulletCtrl  (0) 2013.07.25
PlayerCtrl_V2  (0) 2013.07.25

using UnityEngine;

using System.Collections;


public class Sparks : MonoBehaviour

{


    public GameObject firstSpark;

    public GameObject secondSpark;

    public AudioClip FirstSound;

    public AudioClip secondSound;

    private int hit = 0;


    void OnCollisionEnter(Collision Col)

    {

        if (Col.gameObject.tag == "Bullet")

        {

            hit++;

            audio.PlayOneShot(FirstSound, 1.0f);

            GameObject newSpark1 =

                (GameObject)Instantiate(firstSpark, Col.transform.position,

                Quaternion.LookRotation(-Col.transform.position));

            Destroy(newSpark1, 3.0f);

            Destroy(Col.gameObject);

            if (hit >= 3)

            {

                GetComponent<CapsuleCollider>().enabled = false;

                Expolosion();

            }

        }

    }

            void Expolosion()

            {

                audio.PlayOneShot(secondSound, 1.0f);

                gameObject.AddComponent<Rigidbody>();

                GetComponent<Rigidbody>().AddForce(Vector3.up*1000f);


                GameObject newSpark2 = (GameObject)Instantiate (secondSpark,transform.position,Quaternion.identity);


                Destroy(newSpark2, 5.0f);

            Destroy(gameObject, 0.2f);

            }

        }


'유니티3D > 예제' 카테고리의 다른 글

Bullet  (0) 2013.08.06
MyGizmo.cs  (0) 2013.08.06
bulletCtrl  (0) 2013.07.25
PlayerCtrl_V2  (0) 2013.07.25
PlayerCrtl  (0) 2013.07.25

using UnityEngine;
using System.Collections;

public class BulletCtrl : MonoBehaviour {
 
 public float Speed = 10.0f;
 

 // Use this for initialization
 void Start () {
  rigidbody.AddForce(transform.forward*Speed);
            // 힘을 넣는.addForce...
  
 }
 
}

'유니티3D > 예제' 카테고리의 다른 글

MyGizmo.cs  (0) 2013.08.06
Spark.cs  (0) 2013.08.06
PlayerCtrl_V2  (0) 2013.07.25
PlayerCrtl  (0) 2013.07.25
PlayerCtrl_소스  (0) 2013.07.24

+ Recent posts