Projektik/Assets/Scripts/Rozbitie.cs

24 lines
673 B
C#
Raw Permalink Normal View History

2021-08-15 09:33:25 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Rozbitie : MonoBehaviour
{
public bool broken = false;
public GameObject rozbite;
// Start is called before the first frame update
void OnCollisionEnter(Collision coll) {
Debug.Log(coll.relativeVelocity.magnitude);
if(!broken && coll.gameObject.name != "Bean"){
if(coll.relativeVelocity.magnitude > 3f || coll.relativeVelocity.magnitude < -3f){
Instantiate(rozbite, transform.position, transform.rotation);
Destroy(transform.gameObject);
broken = true;
}
}
}
}