using UnityEngine;
using System.Collections;
public class lookat : MonoBehaviour {
public Transform target;
public GameObject bulletprafbs;
public Transform shootpoint;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.LookAt(target); //此脚本加在带着炮管的球=transform/ target=鼠标移动的胶囊体
GameObject obj = Instantiate(bulletprafbs, shootpoint.position, transform.rotation)as GameObject; //obj =炮弹小球
Destroy(obj, 2);
}
}
***********************************************************************************
using UnityEngine;
using System.Collections;
public class BulletMove : MonoBehaviour {
public float speed =0.1f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(transform.forward * Time.deltaTime * speed,Space.World); //transform=炮弹小球 此脚本加在小球上
//transform.Translate(transform.forward * Time.deltaTime * speed, Space.World);
}
}