Created
January 14, 2017 10:22
-
-
Save johnlanz/af2baa326fbc7163971fb213faeccbb0 to your computer and use it in GitHub Desktop.
Shooting Projectile using invector melee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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