Unity - A计划(永久有效期) 扫二维码继续学习 二维码时效为半小时

(196评价)
价格: 3989.00元
老师按照视频代码打的为什么还会报错
红衣乘鹤入天门发起了问答2019-04-30
2
回复
213
浏览
using UnityEngine;

public class shoot : MonoBehaviour {

	public GameObject bullet;
	public float speed = 5;

	// Use this for initialization
	void Start () {
		Debug.Log ("--Hello dazhuankuai!");

		//GameObject.Instantiate(bullet,transform.position,transform.rotation); 
	}
	
	// Update is called once per frame
	void Update () {
		//Debug.Log ("--Hello dazhuankuai! Update");

		if( Input.GetMouseButtonDown(0)  )
		{	
			GameObject b = GameObject.Instantiate (bullet, transform.position, transform.rotation);

            Rigidbody rgd = b.GetComponent<Rigidbody>();
			rgd.velocity = transform.forward * speed;
	}
  }
}

所有回复
  • 老师_Trigger 2019-04-30

    同学你好,老师这边是没有问题的,可以下载一下老师源码对比看看,尝试把VS关掉再打开试试,不行的话就转换一下类型试试:

    GameObject b = (GameObject)GameObject.Instantiate(bullet,transform.position,transform.rotation);

    还有-4条回复,点击查看
    你还没有登录,请先登录注册
发表回复
你还没有登录,请先 登录或 注册!