Game Development Reference
In-Depth Information
var explosionParticle : GameObject;
private var _smokeTrail : ParticleSystem;
function Awake () {
_smokeTrail =
GetComponentInChildren.<ParticleSystem>();
}
function Start () {
Invoke("KillObject", timeOut);
}
function OnCollisionEnter (others : Collision) {
var contactPoint : ContactPoint =
others.contacts[0];
var rotation : Quaternion =
Quaternion.Euler(Vector3.up);
GameObject.Instantiate(explosionParticle,
contactPoint.point, rotation);
KillObject();
}
private function KillObject () {
if (_smokeTrail != null) {
_smokeTrail.Stop();
_smokeTrail.loop = false;
}
GameObject.Destroy(gameObject);
}
// C# user:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(ConstantForce))]
Search WWH ::




Custom Search