Skip to content

Instantly share code, notes, and snippets.

@johnlanz
Created January 14, 2017 10:22
Show Gist options
  • Save johnlanz/af2baa326fbc7163971fb213faeccbb0 to your computer and use it in GitHub Desktop.
Save johnlanz/af2baa326fbc7163971fb213faeccbb0 to your computer and use it in GitHub Desktop.
Shooting Projectile using invector melee
using UnityEngine;
using System.Collections;
public class vProjectile : MonoBehaviour
{
public GameObject particleOnCollision;
public float speed = 10f;
void Start()
{
var coll = GetComponent<Collider>();
//yield return new WaitForSeconds(0.1f);
coll.isTrigger = false;
}
void Update()
{
transform.Translate(Vector3.forward * speed * Time.deltaTime);
}
void OnCollisionEnter(Collision other)
{
if (particleOnCollision != null)
{
GameObject impactParticle = Instantiate(particleOnCollision, transform.position, transform.rotation) as GameObject;
}
Destroy(gameObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment