【发布时间】:2021-06-14 15:49:41
【问题描述】:
我是 Unity 的新手,我试图让玩家在开始时跳起来。 我有以下代码
using System.Collections;
using UnityEngine;
public class playermove : MonoBehaviour
{
public float Force = 20f;
// Start is called before the first frame update
void Start()
{
Rigidbody.AddForce(0f, 0f, 200f);
}
// Update is called once per frame
void Update()
{
}
}
它向我抛出以下错误
Assets\playermove.cs(10,9): error CS0120: An object reference is required for the non-static field, method, or property 'Rigidbody.AddForce(float, float, float)'
【问题讨论】:
-
请使用正确的标签!仅仅因为您使用的是某个 IDE 并不意味着您的问题实际上与该 IDE 有关。请注意,
unityscript是或更好的是曾经是一种 JavaScript 风格,类似于早期 Unity 版本中使用的自定义语言,并且现在早已弃用。你的代码当然在c#