ofb/Assets/Scripts/ProjectileBehavior.cs

29 lines
594 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ProjectileBehavior : MonoBehaviour
{
public bool pinned = false;
public void Explode()
{
Destroy(this.gameObject);
}
public void Pin()
{
this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
}
public void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "wall")
{
Explode();
}
}
}