So, I’m creating a game, I make one small change to my code, and BAM! I get hit with a ton of errors. I’ve tried going through them one by one to fix them, but nothing.
Here is the problem code for context,
using UnityEngine;
public class Movement : MonoBehaviour
{
public Rigidbody2D rb;
public float move = 50f;
public float JumpHeight = 50f;
public float moveJump = 0f;
// Update is called once per frame
void FixedUpdate()
{
public Collision wackit;
if ( Input.GetKey("d") )
{
rb.AddForce(new Vector2(move, moveJump));
}
if ( Input.GetKey("a") )
{
rb.AddForce(new Vector2(-move, moveJump));
}
if (wackit.collider.tag == "Ground")
{
if ( Input.GetKey("w") )
{
rb.AddForce(new Vector2(moveJump, JumpHeight));
}
}
}
}
As has already been said to you, we cannot help you fix issues if you don’t give us the errors. And when it was asked previously, providing just the error codes is basically useless for anyone to help you out. The full error message tells us the location of the issue.
But at a guess I’m going to say that you haven’t assigned a rigidbody to your public variable through the inspector yet.
Expect to see this error a LOT. It’s easily the most common thing to do when working. Learn how to fix it rapidly. It’s easy. See the above link for more tips.
This is the kind of mindset and thinking process you need to bring to this problem: