i am new to coding and my code isnt working it alsways gives an error
public class Character : MonoBehaviour
// Start is called before the first frame update
rb = GetComponent<Rigidbody>();
speed = 10.0f;
// Update is called once per frame
//Move the Rigidbody to the right constantly at speed you define (the red arrow axis in Scene view)
rb.velocity = new Vector3(rb.velocity.x + 0.03f, rb.velocity.y, rb.velocity.z);;
Make sure there is a Rigidbody component on your character and collider,
and make sure the name of the script is matching the public class name.
We need to know which error is is before we can help you out.
Hi! Some advice on asking questions in a place like this:
When asking for help with an error, you should clearly state what’s the problem.
What did you do, what did you expect to happen and what happened.
You should really read the error message thoroughly as beginners tend to panic when errors happen and they don’t even try to understand them.
You should fix formatting of your question so all of your code is actually in a code block.
To answer your question:
I’m assuming from the looks of your inspector that you
Character class is not in a file called
Character.cs. For MonoBehaviours and ScriptableObjects to work properly there should be only one root class in a file that’s named exactly as the class.