炮塔 跟随

来源:互联网 发布:我的世界手机版js枪械 编辑:程序博客网 时间:2024/04/29 16:48

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);
}
}


原创粉丝点击