20 lines
552 B
C#
20 lines
552 B
C#
using RayFire;
|
|
using UnityEngine;
|
|
|
|
public class Bullet : MonoBehaviour
|
|
{
|
|
public float hitForcePercent = .5f;
|
|
private int hitLimit = 1;
|
|
|
|
private void OnCollisionEnter(Collision collision)
|
|
{
|
|
var rigd = collision.gameObject.GetComponent<RayfireRigid>();
|
|
if (rigd == null)
|
|
return;
|
|
if (collision.gameObject.GetComponent<MeshFilter>().sharedMesh.name != "Cube")
|
|
return;
|
|
rigd.physics.velocity = this.GetComponent<Rigidbody>().velocity * hitForcePercent;
|
|
rigd.Demolish();
|
|
}
|
|
}
|