I have a collision script that's attached to my player (mainCamera) and bullet prefab.
void onCollisionEnter(Collision collision)
{
Debug.Log("Collision running");
if(collision.gameObject.tag == "Enemy" && this.gameObject.tag == "MainCamera")
{
Debug.Log("Hit Enemy");
if (Controller.Health > 0)
{
Controller.Health -= .2f;
}
} else if (collision.gameObject.tag == "Scenary" && this.gameObject.tag == "Bullet")
{
Debug.Log("Bullet hits Scenary");
Destroy(this.gameObject);
} else if (collision.gameObject.tag == "Enemy" && this.gameObject.tag == "Bullet")
{
Debug.Log("Bullet hits Enemy");
Destroy(this.gameObject);
EnemyScript.Health-=.2f;
}
}
None of my debug logs are being set off. I have proper tags for all of the objects, a rigidbody and sphere collider on the sphere bullet, a sphere collider on the camera, mesh colliders on scenary, and box collider on the enemy which is a cube. None of my is Triggers are ticked. The bullet also has gravity, and it falls after a certain point. It can collide with the box and stop; however when it hits the wall plane or the floor plane, the bullet falls or goes through sometimes, but also sometimes works and hits the wall and stops or hits the floor and stays there until it gets destroyed. Not entirely sure where the problem is.