C# Unity 5球不会移动没有错误
我有一个简单的默认unity 3d球体。当我使用箭头键(在输入中设置)时,它有一个使用刚体组件附加到它的脚本。它是用来移动的,但它不做任何操作。没有控制台错误。这里没有我的脚本C# Unity 5球不会移动没有错误,c#,unity3d,C#,Unity3d,我有一个简单的默认unity 3d球体。当我使用箭头键(在输入中设置)时,它有一个使用刚体组件附加到它的脚本。它是用来移动的,但它不做任何操作。没有控制台错误。这里没有我的脚本 using UnityEngine; using System.Collections; public class PlayerController : MonoBehaviour { private Rigidbody PhysicsRB; public float speed; void Start ()
using UnityEngine;
using System.Collections;
public class PlayerController : MonoBehaviour {
private Rigidbody PhysicsRB;
public float speed;
void Start ()
{
speed = 5;
PhysicsRB = GetComponent<Rigidbody>();
}
void Fixedupdate () {
float MoveH = Input.GetAxis ("Horizontal");
float MoveV = Input.GetAxis ("Vertical");
Vector3 movement = new Vector3 (MoveH, 0.0f, MoveV);
PhysicsRB.AddForce (movement * speed);
}
}
使用UnityEngine;
使用系统集合;
公共类玩家控制器:单行为{
私人刚体物理学RB;
公众浮标速度;
无效开始()
{
速度=5;
PhysicsRB=GetComponent();
}
无效固定更新(){
float MoveH=Input.GetAxis(“水平”);
float MoveV=Input.GetAxis(“垂直”);
矢量3移动=新矢量3(移动H,0.0f,移动V);
PhysicsRB.AddForce(移动*速度);
}
}
将“Fixedupdate”更改为“Fixedupdate”。还要确保文件名与类名相同。在你的例子中,你的脚本应该被称为PlayerController.cs。我是新的我该怎么做哦,我看我已经勾选了它。你真的该怎么做Unity's它给出了一步一步的视频说明,说明了如何做你正在做的事情,并且每个视频都有一份完整的代码副本作为参考来检查。