C# 我一直试图让我的Unity 2D播放器移动,但看起来我在脚本中犯了一个错误,我可以';找不到
我试着让我的团结球员移动。我开发了一个2D游戏,并使用此脚本尝试移动:C# 我一直试图让我的Unity 2D播放器移动,但看起来我在脚本中犯了一个错误,我可以';找不到,c#,unity3d,C#,Unity3d,我试着让我的团结球员移动。我开发了一个2D游戏,并使用此脚本尝试移动: 使用系统集合; 使用System.Collections.Generic; 使用UnityEngine; 公共类玩家控制器:单行为{ 公众浮标速度; 私有刚体2d rb; 私有向量2移动速度; void Start(){ rb=GetComponent(); } 无效更新(){ Vector2.moveInput=新的Vector2(Input.GetAxis(“水平”)、Input.GetAxis(“垂直”); mov
使用系统集合;
使用System.Collections.Generic;
使用UnityEngine;
公共类玩家控制器:单行为{
公众浮标速度;
私有刚体2d rb;
私有向量2移动速度;
void Start(){
rb=GetComponent();
}
无效更新(){
Vector2.moveInput=新的Vector2(Input.GetAxis(“水平”)、Input.GetAxis(“垂直”);
moveVelocity=moveInput.normalized*速度;
}
void FixedUpdate(){
rb.移动位置(rb.位置+移动速度*时间固定时间);
}
}
当我想要打开unity时,总会有这样的错误: Assets\PlayerController.cs(19,13):错误CS0117:“Vector2”不包含“moveInput”的定义 Assets\PlayerController.cs(20,20):错误CS0103:名称“moveInput”在当前上下文中不存在
我希望我能得到一些答案!谢谢大家! 在
Vector2
和moveInput
之间放置一个句点
原件:
Vector2.moveInput...
固定的:
Vector2 moveInput...
调用Vector2.moveInput
假定类Vector2
有一个名为moveInput
的静态变量
Vector2 moveInput...