【问题标题】:The type or namespace name 'Vector' could not be found (are you missing a using directive or an assembly reference?)找不到类型或命名空间名称“Vector”(是否缺少 using 指令或程序集引用?)
【发布时间】:2022-12-05 21:38:58
【问题描述】:

`

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour
{
    [SerializeField]
    public float speed = 3.5f;
    
    // Start is called before the first frame update
    void Start()
    {
        transform.position = new Vector(63, 15, 51); 
    }

    // Update is called once per frame
    void Update()
    {
       float horizontalInput = Input.GetAxis("Horizontal");

       transform.Translate(Vector3.right *horizontalInput *speed * Time.deltaTime);

    }
}

`

我试着用谷歌搜索这个问题,我找到了解决方案,但我没有打错字,“Vector3”和 Time.deltaTime 也没有被突出显示

【问题讨论】:

    标签: c# visual-studio unity3d


    【解决方案1】:

    找不到类型或命名空间名称“Vector”

    我看到的唯一矢量是

    transform.position = new Vector(63, 15, 51); 
    

    也许将其更改为:

    transform.position = new Vector3(63, 15, 51); 
    

    更新功能看起来不错,你确定错误发生在那里吗?

    【讨论】:

      猜你喜欢
      • 2013-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-14
      • 2012-05-01
      • 2020-11-28
      • 2015-06-12
      • 2015-04-19
      相关资源
      最近更新 更多