36 lines
760 B
C#
Executable file
36 lines
760 B
C#
Executable file
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SandBlock : MonoBehaviour
|
|
{
|
|
public Animator Animation;
|
|
public AudioSource Sand;
|
|
public BoxCollider2D Collider;
|
|
private void Start()
|
|
{
|
|
Animation = GetComponent<Animator>();
|
|
|
|
}
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
if (collision.tag == "Player")
|
|
{
|
|
Invoke("AnimPlay", 1f);
|
|
|
|
}
|
|
}
|
|
private void AnimPlay()
|
|
{
|
|
Animation.SetTrigger("Play");
|
|
Sand.Play();
|
|
Destroy(Collider);
|
|
Invoke("OnDestroy", 1.4f);
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
Destroy(this.gameObject);
|
|
}
|
|
|
|
}
|