Unity子弹发射器C#脚本

using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class Fire : MonoBehaviour {
public Transform FirePoint;
public GameObject bulletPrefab;
// Use this for initialization
void Start () {
Debug.Log (transform.eulerAngles);
Debug.Log (Quaternion.Euler (transform.eulerAngles));
Debug.Log (transform.rotation);
}

// Update is called once per frame
void Update () {
if (Input.GetMouseButton(0)) {
// Debug.Log ("leftmouse");
//创建子弹
object obj = Instantiate(bulletPrefab,FirePoint.position,FirePoint.rotation);
//   销毁子弹
GameObject bullet = obj as GameObject;
Destroy (bullet, 3);
}
}
}

你可能感兴趣的:(Unity)