ofb/Assets/Scripts/ProjectileBehavior.cs

29 lines
628 B
C#
Raw Permalink Normal View History

2023-04-11 19:55:24 -07:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ProjectileBehavior : MonoBehaviour
{
2023-04-11 19:55:24 -07:00
public bool pinned = false;
public void Explode()
{
2023-04-11 19:55:24 -07:00
Destroy(this.gameObject);
}
public void Pin()
{
2023-04-11 19:55:24 -07:00
this.gameObject.GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
}
public void OnCollisionEnter2D(Collision2D col)
{
if (col.gameObject.tag == "wall" || col.gameObject.tag == "Player")
{
2023-04-11 19:55:24 -07:00
Explode();
}
}
}