ofb/Assets/Scripts/ProjectileBehavior.cs

24 lines
574 B
C#
Raw Normal View History

2023-04-11 19:55:24 -07:00
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();
}
}
}