Wie kann ich das ("Top-level statements must precede namespace and type declarations") fixen?
Das kommt, wenn ich spielen will:
Assets\PipeSpawner.cs(33,9): error CS8803: Top-level statements must precede namespace and type declarations.
Aber es geht nicht.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PipeSpawner : MonoBehaviour
{
public GameObject pipe;
public float spawnRate = 2;
public float timer = 0;
// Start is called before the first frame update
void Start()
{
spawnPipe();
}
// Update is called once per frame
void Update()
{
if (timer < spawnRate)
{
timer = timer + Time.deltaTime;
}
else
{
spawnPipe();
timer = 0;
}
}
void spawnPipe();
}
{
float lowestPoint = transform.position.Y - heigthOffset;
float highestPoint = transform.position.y + heigthOffset;
Instantiate(pipe, new Vector3 (transform.position.x, Random.Range(lowestPoint,highestPoint), 0),transform.rotation);
}
Kann mir jemand sagen, was falsch ist?
C Sharp,
Code,
Visual Studio,
Unity