blob: 2ce736cf67754abae0f049c91b13a9e209a497bb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
using MontanaJohns.Actors;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BoobyTrap : MonoBehaviour
{
[SerializeField] GameObject boobyTrap;
[SerializeField] GameObject spawnPoint;
bool triggered;
private void Start()
{
Instantiate(spawnPoint);
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player" && !triggered)
{
triggered = true;
gameObject.GetComponent<SpriteRenderer>().sprite = null;
Instantiate(boobyTrap, spawnPoint.transform.position, Quaternion.identity);
}
}
}
|