the type or namespace name RigidBody2D could not be found
-
I've decided to make 2nd a platformr and I'm learning about eminence. Notice that the syntax screen c# is not even illuminated and then began to get a mistake: The type or namespace name 'RigidBody2D' could not be found (are you missing a using directive or an assembly reference? Though I kind of wrote it right and should work.
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Hero : MonoBehaviour
{
[SerializeField] private float speed = 3f;
[SerializeField] private int lives = 3;
[SerializeField] private float JumpForce = 5f;private RigidBody2D rb; private SpriteRenderer sprite; private void Awake() { rb = GetComponent<RigidBody2D>(); sprite = GetComponentinChildren<SpriteRenderer>(); } private void Update() { if (Input.GetButton("Horzintal")) Run(); } private void Run() { Vector3 dir = transform.right * Input.GetAxis("Horizontal"); transform.position = Vector3.MoveTowards(transform.position, transform.position + dir, speed * Time.deltaTime); }
}
-
Look at what I can't explain in detail, but it's because you didn't choose to open it, more accurately than open scruples. That's how to solve the problem:
In general, you go into your project in Unity, press the Edit-Power Preferences... ♪ That's where you choose External Tools and External Script Editor.