BulletImpact Particals(noch nicht fertig)

This commit is contained in:
pbg2h23akl
2024-06-21 11:28:03 +02:00
parent d91ab65c06
commit 0cfce6e5ff
8 changed files with 5162 additions and 2 deletions

View File

@@ -7,6 +7,8 @@ using UnityEngine;
public class BulletScript : MonoBehaviour
{
public DataBullet dataBullet;
public GameObject particalClash;
public float lifetime = 3f;
private Rigidbody rb;
@@ -30,6 +32,8 @@ public class BulletScript : MonoBehaviour
}
private void OnCollisionEnter(Collision collision){
Debug.Log(collision.gameObject.name);
ContactPoint contact = collision.GetContact(0);
Instantiate(particalClash,transform.position,Quaternion.LookRotation(contact.normal));
GameObject.Destroy(this.gameObject);
}
// Start is called before the first frame update

View File

@@ -0,0 +1,28 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ParticalClash : MonoBehaviour
{
public float lifeTime = 2;
private float time = 0;
private void die(float time, float lifeTime){
if(time > lifeTime){
GameObject.Destroy(this.gameObject);
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
time += Time.deltaTime;
die(time, lifeTime);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4e78e7c61fba07742ae26607d4fa9390
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: