Quantcast
Channel: Questions in topic: "enemy"
Viewing all articles
Browse latest Browse all 1488

Projectile Collision with Enemy not working :(

$
0
0
Hello Devs, I've a projectile with rigidbody and sphere collider and an enemy with collider (is triger Checked) and with tag "enemy".. what I want is when the projectile collides with enemy .. enemy should destroy I'm using this code for Projectile: public class Projectile : MonoBehaviour { public float ProjectileSpeed = 10f; // Use this for initialization void Start () { } // Update is called once per frame void Update () { float amtToMove = ProjectileSpeed * Time.deltaTime; transform.Translate (Vector3.up * amtToMove); if(transform.position.y >= 4.7f) { Destroy(gameObject); } } void onTriggerEnter(Collider other) { if(other.gameObject.tag == "enemy") { Enemy enemy = (Enemy)other.gameObject.GetComponent("Enemy"); enemy.SetPositionAndSpeed(); Destroy(other.gameObject); Destroy(gameObject); } } But still got no luck ... any Help is much appreciated. Best.. .J

Viewing all articles
Browse latest Browse all 1488

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>