'In unity what is C# jump script showing error
On unity using C# I made this jump script to control a player. When I run the code below I get the errors shown below
using UnityEngine;
public class PlayerScript : MonoBehaviour
{
public float JumpForce;
[SerializeField]
bool isGrounded = false;
Rigidbody2D RB;
private void Awake()
{
RB = GetComponent<Rigidbody2D();
}
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.Space))
{
if(isGrounded == true)
{
RB.AddForce(Vector2.up*JumpForce);
isGrounded = false;
}
}
}
O refrences
private void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.CompareTag("ground"))
{
if(isGrounded == false)
{
isGrounded = true;
}
}
}
}
For some reason, I get no error inside of vs code but when I to the game it says what the picture below says. If you have an answer it would really help thanks.
Solution 1:[1]
Make sure you have configured everything correctly. An in-depth tutorial can be found here.
https://code.visualstudio.com/docs/other/unity
The warnings can happen when you change the name of a class or file, and don't fix the script component on the scene game object. It can also give that warning if you change the code while in playmode.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | TheTechn0mancer |
