the answer is ;
using System.Collections.Generic;
using UnityEngine;
public class DW : MonoBehaviour {
public Transform DestroyedVersion;
public float magnitudeCol, radius;
private bool callOnce;
void OnCollisionEnter2D(Collision2D other)
{
if(other.relativeVelocity.magnitude > magnitudeCol && !callOnce)
{
callOnce = true;
Destroy (gameObject);
Instantiate (DestroyedVersion, transform.position, transform.rotation);
}
}
}
TreyH
2
Problem seems to be that your speed is triggering mutliple collisions. Simplest way might be to just mark that you’ve already hit something.
public float magnitudeCol, radius;
private bool canBreak = true;
void OnCollisionEnter2D(Collision2D collision)
{
if(canBreak && collision.relativeVelocity.magnitude > magnitudeCol)
{
canbreak = false;
Destroy (gameObject);
Instantiate (DestroyedVersion, transform.position, transform.rotation);
}
}