I出现了错误“错误cs1061:'strigidbody2d'不包含'Linearvelocity'的定义,并且从此代码中找到了第一个类型的'strigidbody2d'的参数“线性级别”的方法'linearvelocity'可以从此代码中找到:
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Movement : MonoBehaviour
{
private Rigidbody2D rb;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
rb.linearVelocity = new Vector2(Random.Range(-10.0f,-10.0f), Random.Range(-10.0f,-10.0f));
}
// Update is called once per frame
void Update()
{
}
}
我的尝试是制造一个立方体,从一开始就获得了随机速度,并沿着那条路径持续。我期望从线性级别的情况下遇到错误,但是显然不存在。
linearVelocity
:
velocity