Answer the question
In order to leave comments, you need to log in
Variable type Rigidbody2D cannot be assigned to Rigidbody2D, how to solve the problem?
using UnityEngine;
public class player : MonoBehaviour
{
public float jumpForce = 10f;
public Rigidbody2D rb;
void Start()
{
rb = GameObject.FindWithTag("player").GetComponent<Rigidbody2D>();
}
void Update()
{
if(Input.GetMouseButton(0))
{
rb.velocity = Vector2.up * jumpForce;
}
}
}
Выдает ошибку: The variable rb of player has not been assigned.
Answer the question
In order to leave comments, you need to log in
Do you have one player? Throw it through the unity interface (just transfer the object that has rb to the appropriate property).
If there are several, do it as a separate script or object.
Maybe your player doesn't have rb. Or there is no object with the corresponding tag at all.
You can try using new
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question