我正在从头开始用 Unity 3D 制作游戏。
我收到一个错误
UnassignedReferenceException:'MoveAround' 的变量 BullitPrefab 尚未分配。您可能需要在检查器中分配 MoveAround 脚本的 BullitPrefab 变量。UnityEngine.Object.Internal_InstantiateSingle (UnityEngine.Object data, Vector3 pos, Quaternion rot) (at C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:44) UnityEngine.Object.Instantiate (UnityEngine.Object original , Vector3 位置, 四元数旋转) (在 C:/BuildAgent/work/812c4f5049264fad/Runtime/ExportGenerated/Editor/UnityEngineObject.cs:53) MoveAround.Update () (在 Assets/MoveAround.js:22)
我在以下代码中遇到错误
enter code here
var speed = 3.0;
var rotateSpeed = 3.0;
var bullitPrefab:Transform;
function Update ()
{
var controller : CharacterController = GetComponent(CharacterController);
//Rotate around y - axis
transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);
//Move forward / bacward
var forward = transform.TransformDirection(Vector3.forward);
var curSpeed = speed * Input.GetAxis("Vertical");
controller.SimpleMove(forward * curSpeed);
if(Input.GetButtonDown("Jump"))
{
var bullit = Instantiate(bullitPrefab, gameObject.Find("spwanPoint").transform.position, Quaternion.identity);
}
}
@script RequireComponent(CharacterController)
这是教程的链接 http://www.youtube.com/watch?v=wfpZ7_aFoko&list=PL11F87EB39F84E292