using UnityEngine;
using System.Collections;
public class Boss1Col : MonoBehaviour {
public int health=3;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
void OnCollisionEnter(){
health = health - 1;
Debug.LogWarning ("One Health Lost");
if (health == 0) {
Debug.LogWarning ("Destruction shoud have happened");
}
}
}
i searched the forums for solution but none work for some reason so i’m wondering why my collision is not working,is trigger is not checked on the collider, both of the object colliding have rigid bodies and are kinetamic.what is the possible problem.also i have no script overwriting the colision class.
using UnityEngine;
using System.Collections;
public class BulletCollision : MonoBehaviour {
public GameObject explosion;
void OnCollisionEnter(Collision col){
if (col.gameObject.tag == "Cube") {
Instantiate(explosion,transform.position,Quaternion.identity);
Destroy (gameObject);
}
using UnityEngine;
using System.Collections;
public class BulletMove : MonoBehaviour {
public float bulletSpeed;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(bulletSpeed!=null){
transform.position += new Vector3(0,bulletSpeed,0);
}
if (transform.position.y > 5) {
Destroy(gameObject);
}
}
}
these are the scripts for the bullet incase something wrong with the bulet, plus thecolllision doeswork just not with the bullet for some reason
Is it a 2D game ?
Then try OnCollisionEnter2D
Regards,
LifeArtist
Are your objects to fast? If so they can avoid a frame check and the objects will just pass right through each other. Been down this road and other posters clued me into this. I addressed the parameters and the problem was found and repaired.