using UnityEngine;
using System.Collections;
public class SpawnBulletPoint : MonoBehaviour {
public float radius = 2f;
void OnDrawGizmos()
{
Gizmos.color = Color.green;//此线框球状物的颜色是红色的
Gizmos.DrawSphere(transform.position, radius);//创建一个线框球形
}
}
using UnityEngine;
using System.Collections;
public class BulletController : MonoBehaviour {
public float speed = 10f;
public float distance = 0.1f;
private LayerMask mask;
using UnityEngine;
using System.Collections;
public class SpawnBullet : MonoBehaviour {
public GameObject bullet;
public Transform Spawnpoint;
void OnGUI()
{
if(GUILayout.Button("SpawnBullet"))
{
Instantiate(bullet,Spawnpoint.position,Quaternion.identity);
}
}
}
不必说你也知道,只是克隆出子弹预设。下面我们将这个脚本绑定在摄像机上面,该拖拽的全都拖拽上去。我们的例子大概完成了。运行一下看看: