Files
ICDBWTMAG2020/Assets/Scripts/DirtScript.cs
T

27 lines
547 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DirtScript : MonoBehaviour
{
public GameObject Spray;
private bool sprayed = false;
void OnCollisionEnter2D(Collision2D other){
if(other.gameObject.name == "SprayBottle" && !sprayed)
{
sprayed = true;
Instantiate(Spray, new Vector2(this.transform.position.x, this.transform.position.y), Quaternion.identity);
}
if(other.gameObject.name == "Rag" && sprayed)
{
Destroy(this.gameObject);
}
}
}