Initialer Upload neues Unity-Projekt
This commit is contained in:
26
Assets/Explosion System/Scripts/GraphicExplosion.cs
Normal file
26
Assets/Explosion System/Scripts/GraphicExplosion.cs
Normal file
@ -0,0 +1,26 @@
|
||||
// script to render explosion
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class GraphicExplosion : MonoBehaviour {
|
||||
public float loopduration;
|
||||
private float ramptime=0;
|
||||
private float alphatime=1;
|
||||
void Update () {
|
||||
Destroy(gameObject, 7);
|
||||
ramptime+=Time.deltaTime*2;
|
||||
alphatime-=Time.deltaTime;
|
||||
float r = Mathf.Sin((Time.time / loopduration) * (2 * Mathf.PI)) * 0.5f + 0.25f;
|
||||
float g = Mathf.Sin((Time.time / loopduration + 0.33333333f) * 2 * Mathf.PI) * 0.5f + 0.25f;
|
||||
float b = Mathf.Sin((Time.time / loopduration + 0.66666667f) * 2 * Mathf.PI) * 0.5f + 0.25f;
|
||||
float correction = 1 / (r + g + b);
|
||||
r *= correction;
|
||||
g *= correction;
|
||||
b *= correction;
|
||||
GetComponent<Renderer>().material.SetVector("_ChannelFactor", new Vector4(r,g,b,0));
|
||||
GetComponent<Renderer>().material.SetVector("_Range", new Vector4(ramptime,0,0,0));
|
||||
GetComponent<Renderer>().material.SetFloat("_ClipRange", alphatime);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
8
Assets/Explosion System/Scripts/GraphicExplosion.cs.meta
Normal file
8
Assets/Explosion System/Scripts/GraphicExplosion.cs.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68ef2ef05dc70784aae5ae2f583e4356
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
30
Assets/Explosion System/Scripts/PhysicalExplosion.cs
Normal file
30
Assets/Explosion System/Scripts/PhysicalExplosion.cs
Normal file
@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class PhysicalExplosion : MonoBehaviour
|
||||
{
|
||||
public float Radius;// explosion radius
|
||||
public float Force;// explosion forse
|
||||
void Update ()
|
||||
{
|
||||
Collider[] hitColliders = Physics.OverlapSphere(transform.position, Radius);// create explosion
|
||||
for(int i=0; i<hitColliders.Length; i++)
|
||||
{
|
||||
if(hitColliders[i].CompareTag("CanDestroy"))// if tag CanBeRigidbody
|
||||
{
|
||||
if(!hitColliders[i].GetComponent<Rigidbody>())
|
||||
{
|
||||
hitColliders[i].gameObject.AddComponent<Rigidbody>();
|
||||
}
|
||||
hitColliders[i].GetComponent<Rigidbody>().AddExplosionForce(Force, transform.position, Radius, 0.0F); // push game object
|
||||
}
|
||||
|
||||
}
|
||||
Destroy(gameObject,0.2f);// destroy explosion
|
||||
}
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
Gizmos.color = Color.red;
|
||||
Gizmos.DrawWireSphere(transform.position,Radius);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 774c6fe16d827fe4685d1a5d46eb00cd
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
25
Assets/Explosion System/Scripts/light_control.cs
Normal file
25
Assets/Explosion System/Scripts/light_control.cs
Normal file
@ -0,0 +1,25 @@
|
||||
// script to delete light after explosition
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class light_control : MonoBehaviour {
|
||||
private float timeout = 0.5f;
|
||||
public Light Light;
|
||||
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
void Update () {
|
||||
if(timeout>0.1f)
|
||||
{
|
||||
timeout-=Time.deltaTime;
|
||||
Light.range=15;
|
||||
}
|
||||
else
|
||||
{
|
||||
Light.range=0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
12
Assets/Explosion System/Scripts/light_control.cs.meta
Normal file
12
Assets/Explosion System/Scripts/light_control.cs.meta
Normal file
@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d9aa3bcb24514d56ba9c4632ed8fd98
|
||||
timeCreated: 1481899373
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user