Hi lads Im new to coding,I was trying to make my first game,but it shows the error code CS8803:Top-level statements must precede namespace and type declarations How do I fix it?Heres my code btw
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour
{
public float speed = 10f;
Rigidbody rb;
}
void Start()
{
rb = GetComponent<Rigidbody>();
}
void Update()
{
float xMove = Input.GetAxisRaw("Horizontal");
float zMove = Input.GetAxisRaw("Vertical");
rb.velocity = new Vector3(xMove, rb.velocity.y, zMove) * 10f;
}
I tried many times
I was follow a tutorial online,I dont think I missed a step Thanks alot.