简体   繁体   English

(Unity3D) 错误 CS1503:参数 2:无法从“浮动”转换为“UnityEngine.Space”

[英](Unity3D) error CS1503: Argument 2: cannot convert from 'float' to 'UnityEngine.Space'

I'm trying to learn c# in unity and when I follow an old tutorial on using the mouse to look and move I get this error.我正在尝试统一学习 c#,当我按照有关使用鼠标查看和移动的旧教程进行操作时,出现此错误。 It seems like unity has been greatly updated since then.从那时起,Unity 似乎有了很大的更新。 I figured I can try and learn the c code anyway.我想无论如何我都可以尝试学习c代码。 Is there any simple way to make it work?有什么简单的方法可以让它工作吗? I'm trying to move a ball around in first person view.我正在尝试以第一人称视角移动球。

using UnityEngine;

public class Motion : MonoBehaviour
{

    
    public float speedx = .1f;
    

    void Update()
    {
        float movement = Input.GetAxis ("Vertical");
        movement *= Time.deltaTime;
        
        this.transform.Translate
        (Vector3.forward, movement);
        
        float xDirection = Input.GetAxis("Horizontal");
        
        Vector3 moveDirection = new Vector3(xDirection, 0.1f, movement);
        
        transform.position += moveDirection * speedx;
        
        
    }
}

(Vector3.forward , motion) 应该是 (Vector3.forward * movement)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Unity C# 错误:(12,47):错误 CS1503:参数 2:无法从 &#39;System.Collections.Generic.List 转换<UnityEngine.GameObject> &#39; 浮&#39; - Unity C# error: (12,47): error CS1503: Argument 2: cannot convert from 'System.Collections.Generic.List<UnityEngine.GameObject>' to 'float' CS1503:参数 3:无法从“double”转换为“UnityEngine.Quaternion”帮助! 统一二维 c# - CS1503: Argument 3: cannot convert from 'double' to 'UnityEngine.Quaternion' HELP! unity 2D c# 错误 CS1503:参数 1:无法从“UnityEngine.XR.XRNode”转换为“string” - error CS1503: Argument 1: cannot convert from 'UnityEngine.XR.XRNode' to 'string 我需要帮助解决 Unity 3D 中的 CS1503 错误“无法从'字符串转换为'浮点'” - I need help resolving CS1503 error “Can not convert from 'string to 'float' ” in Unity 3D 错误CS1503:参数“#2”无法将“对象”表达式转换为类型“ UnityEngine.Vector3” - error CS1503: Argument `#2' cannot convert `object' expression to type `UnityEngine.Vector3' CS1503 参数 1:无法从 'string' 转换为 'string[*,*]' - CS1503 Argument1: cannot convert from 'string' to 'string[*,*]' 如何解决此错误“错误 CS1503:参数 1:无法从‘void’转换为‘bool’” - How to resolve this error "error CS1503: Argument 1: cannot convert from 'void' to 'bool'" 出现错误 CS1503:“参数 1:无法从 'System.Diagnostics,PerformanceCounter' 转换为 'int' - Getting Error CS1503: "Argument 1: Cannot convert from 'System.Diagnostics,PerformanceCounter' to 'int' C# 错误 CS1503 参数 1:无法从“字符串”转换为“字符” - C# Error CS1503 Argument 1: cannot convert from 'string' to 'Character' 有限 State 机器的问题“错误 CS1503:参数 1:无法从‘UIManager’转换为‘GameStateAbstract’” - Problem with a Finite State Machine "error CS1503: Argument 1: cannot convert from 'UIManager' to 'GameStateAbstract'"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM