您好,我的问题是,我尝试从游戏对象中制作出bulletprefab spawm,但这是* error CS1061:
'Transform'不包含'Position'的定义,没有可访问的扩展方法“位置”,接受可以找到“转换”类型*。
不要让我那样做。这是代码lanzador是生成器,而balaprefab是bulletprefab
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CtrlJugador : MonoBehaviour
{
public Rigidbody balaprefab;
public Transform Lanzador;
void Start()
{
}
// Update is called once per frame
void Update()
{
if (Input.GetButton("Fire1"))
{
Instantiate(balaprefab, Lanzador.Position, Quaternion.identity);
}
}
}
您好,我的问题是,我尝试从游戏对象中制作出bulletprefab spawm,但此* error CS1061:'Transform'不包含'Position'的定义,并且没有可访问的扩展名...
信任错误消息!编译器告诉您myTransform.Position
不存在,这意味着它不存在。我做了一个快速的谷歌搜索,发现这个:
要知道的一件事:统一脚本中的字段都命名为camelCase。没有字段以大写字母开头。