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."
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);
}
}
}
The class name contains extra spaces.
public class car control
^
© 2024 OneMinuteCode. All rights reserved.