老师为什么您视频里面的这句话
using UnityEngine;
public class Shoot : MonoBehaviour {
public GameObject bullet;
public float speed = 5;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(0))
{
GameObject b =(GameObject)Instantiate(bullet, transform.position, transform.rotation);
Rigidbody rgd = b.GetComponent<Rigidbody>();
rgd.velocity = transform.forward * speed;
}
}
}
第十三行的GameObject b =(GameObject)Instantiate(bullet, transform.position, transform.rotation);没有加括号VS不会报错 而我编辑的时候输入GameObject b =GameObject.Instantiate(bullet, transform.position, transform.rotation);就会报错 去群里面问了几为大佬才知道要强制转换,但为什么您的视频里面不需要转换呢。