Unity Console Error Handling Is Not Solvable

Asked 1 years ago, Updated 1 years ago, 66 views

I think the fifth line says that ; and {} are missing due to a console error, but it should not be necessary for the public class.
Where do I put {}?

Also, what does it mean when it says "Top level statement must precede namespace and type declarations."

console error screen:
src=

Tried

MonoBehavior followed by ; and the error disappeared, so I tried {} in various parts of the fifth line, but the error remained.

Code

using System.Collections;
using System.Collections.General;
using UnityEngine;

public class car control:MonoBehavior
{
    float Speed = 0;
    float LimitSpeed = 70f;
    // Start is called before the first frame update


    // Update is called once per frame
    voidFixedUpdate()
    {
        Rigidbody rb = this.GetComponent<Rigidbody>();
        Vector3 force = new Vector3 (10f, 0.0f, 0.0f);
        rb.AddForce (force, ForceMode.Force);

        if(rb.velocity.magnitude>LimitSpeed)
        {
            rb.velocity = new Vector 3 (rb.velocity.x/1.1f, rb.velocity.y, rb.velocity.z/1.1f);
        }
    }
}

c# unity3d

2022-09-30 19:22

1 Answers

The class name contains extra spaces.

public class car control
                ^


2022-09-30 19:22

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.