Hallo Community,
ich bräuchte eure Hilfe.
Und zwar hab ich eine Spieler-Figur und zahlreiche Objekte, die fallen. Nun hab ich es hinbekommen, dass die Objekte gezählt werden und veschwinden.
Nur wie lass ich sie willkürlich respawnen?
Das Script sieht folgendermaßen aus:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Coin : MonoBehaviour
{
private int coinCounter;
public Text scoreText;
// Start is called before the first frame update
void Start()
{
coinCounter = 0;
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.tag == "Coin")
{
coinCounter++;
Destroy(other.gameObject);
scoreText.text = "Score: " + coinCounter.ToString();
Debug.Log("Score: "+coinCounter);
}
}
}
Kann mir bitte jemand helfen?
Grüße
SueNerdy