I have two objects, an enemy a projectile, the projectile has a rigidbody with Is kinematic checked and it’s Is Trigger is checked in the Collider options.
I was after a log of every time said projectile hit the enemy and did not get it.
But more importantly said game object did not get destroyed.
Any ideas…
using UnityEngine;
using System.Collections;
public class Projectile : MonoBehaviour {
public float ProjectileSpeed;
private Transform myTransform;
// Use this for initialization
void Start ()
{
myTransform = transform;
}
// Update is called once per frame
void Update ()
{
float amtToMove = ProjectileSpeed * Time.deltaTime;
myTransform.Translate(Vector3.up * amtToMove);
if (myTransform.position.y > 6.4f)
Destroy(gameObject);
}
void onTriggerEnter(Collider otherObject)
{
//Debug.Log("We hit " + otherObject.name);
if(otherObject.tag == "enemy")
{
Destroy(otherObject.gameObject);
}
}
}