Fehler im Skript?

Ich probiere gerade ein eigenes Jump and Run Spiel zu Programmieren. Ich wollte eigentlich gerade testen ob ich jetzt mit Lehrtaste springen kann aber dann kahm dieser Error : Assets\Script\Charackter.cs(24,5): error CS8803: Top-level statements must precede namespace and type declarations.

So sieht mein Code aus : using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class Charackter : MonoBehaviour

{

  public float speed = 5.0f;

   

  public Vector3 jump;

  public float jumpForce = 2.0f;

   

  public float jumpHeight = 7f;

  public bool isGrounded;

  private Rigidbody rb;

}

  // Start is called before the first frame update

  void Start()

  {

    speed = 5.0f;

    rb = GetComponent<Rigidbody>();

     

  }

  // Update is called once per frame

  void Update()

  {

    if (Input.GetKey(KeyCode.W))

    {

      transform.Translate(Vector3.forward * Time.deltaTime * speed);

    }

    if (Input.GetKey(KeyCode.S))

    {

      transform.Translate(-1 * Vector3.forward * Time.deltaTime * speed);

    }

    if (Input.GetKey(KeyCode.A))

    {

      transform.Rotate(0, -1, 0);

    }

    if (Input.GetKey(KeyCode.D))

    {

      transform.Rotate(0, 1, 0);

    }

  if (isGrounded)

  {

    if (Input.GetButtonDown("Jump"))

    {

      rb.AddForce(Vector3.up * jumpHeight);

    }

  }

  void OnCollisionEnter(Collision other)

  {

    if (other.gameObject.tag == "Ground")

    {

      isGrounded = true;

    }

  }

  void OnCollisionExit(Collision other)

  {

    if (other.gameObject.tag == "Ground")

    {

      isGrounded = false;

    }

  }

}

  Ich währe sehr Dankbar um Hilfe da ich nicht so viel Ahnung von diesem Thema habe.

Lg

C Sharp, Visual Studio, Unity
Weitere Inhalte können nur Nutzer sehen, die bei uns eingeloggt sind.