Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/280.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 2D播放器移动有问题_C#_Unity3d - Fatal编程技术网

C# 2D播放器移动有问题

C# 2D播放器移动有问题,c#,unity3d,C#,Unity3d,大家好,我们的社区。 我是一个不熟悉编码和C#的人。我开始做一个跳转跑步游戏,在编写movent系统的代码时,我不知道是什么地方出了问题。(我使用Visual studio) 错误代码是 错误CS0103:名称“Moved”在当前上下文中不存在 我的代码是 using System.Collections; using System.Collections.Generic; using UnityEngine; public class NewBehaviourScript : MonoBeh

大家好,我们的社区。 我是一个不熟悉编码和C#的人。我开始做一个跳转跑步游戏,在编写movent系统的代码时,我不知道是什么地方出了问题。(我使用Visual studio) 错误代码是

错误CS0103:名称“Moved”在当前上下文中不存在

我的代码是

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

public class NewBehaviourScript : MonoBehaviour
{    
    public float moveSpeed = 5f;

    // Update is called once per frame
    void Update()
    {
        Vector3 movement = new Vector3(Input.GetAxis("Horizontal"), 0f, 0f);      
        transform.position += movement * Time.deltaTime * moveSpeed;
    }
}

感谢您的帮助。

出现错误的原因是您试图访问脚本中不存在的变量
Moved
。确保您已经创建了变量,并且使用正确的大小写写入了变量名。

Hi,错误不会反映代码-换句话说:此代码不会产生该错误。您能显示实际的错误或代码吗?