


Ошибка c# Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public float speeed;
private Rigidbody rb;
private Vector2 moveInput;
private Vector2 moveVelocity;
private void Start()
{
rb = GetComponent<Rigidbody>();
}
private void Update()
{
moveInput = new Vector2(Input.GetAxis("Horizontal"), Input.GetAxisRaw("Vertical"));
moveVelocity = moveInput.normalized * speeed;
rb.velocity = moveVelocity;
}
void FixedUpdate()
{
rb.MovePosition(rb.position + moveVelocity * Time.fixedDeltaTime);
}
}
Какой текст ошибки? Если жалуется на rb, то вероятная причина в том, что на сцене у объекта с компонентом Player отсутствует компонент Rigidbody.