gimm-platformer-project/Assets/Scripts/startTrigger.cs

27 lines
676 B
C#
Raw Normal View History

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class startTrigger : MonoBehaviour
{
private tetrominoSpawnManager TetrominoSpawnManager;
2021-11-01 23:55:30 -06:00
private bool gameStarted = false;
// Start is called before the first frame update
void Start()
{
TetrominoSpawnManager = FindObjectOfType<tetrominoSpawnManager>();
}
private void OnTriggerEnter2D(Collider2D other)
{
2021-11-01 23:55:30 -06:00
if (other.gameObject.tag == "Player" && !gameStarted)
{
2021-11-01 23:55:30 -06:00
GetComponent<AudioSource>().Play();
TetrominoSpawnManager.spawnTetromino();
2021-11-01 23:55:30 -06:00
gameStarted = true;
}
}
}