)是我的错误信息,这是我的代码
using UnityEngine;
public class PlayerMovement : MonoBehaviour {
// This is a reference to the Rigidbody component called "rb"
public Rigidbody rb;
public float forwardforce = 2000f ;
// We marked this as fixedUpdate because we
// are using it to mess with physics.
void FixedUpdate ()
{
rb.AddForce(0, 0, forwardforce * Time.deltaTime); // Add a force of 2000 on the z-axis
if (Input.Getkey("d")
(
rb.Addforce(500*Time.deltatime, 0, 0);
)
}
}发布于 2022-09-16 09:22:45
根据上面的注释- if语句应该如下所示:
if (Input.Getkey("d"))
{
rb.Addforce(500*Time.deltatime, 0, 0);
}通常,IDE应该为您指出这一点。
发布于 2022-09-16 09:36:16
你在这里犯了个错误
if (Input.Getkey("d")
(
rb.Addforce(500*Time.deltatime, 0, 0);
)你用(),而不是{}。有一个简单的解决方案:
语句{}之后使用
。
if (Input.Getkey("d")
{
rb.Addforce(500*Time.deltatime, 0, 0);
}https://stackoverflow.com/questions/73741703
复制相似问题