Skip to main content
2 of 3
added 391 characters in body
davidpox
  • 31
  • 1
  • 8

Two 2D objects in Unity aren't colliding together

In Unity 5, I have a player shooting a projectile in aim to hit a boss, and inflict damage upon contact with the projectile. Though for some reason, the projectile and boss aren't colliding with each other.

I've done the following;

  • Made sure that both the projectile and boss have a BoxCollider 2D and Rigidbody 2D
  • Made sure that they're on the same Z-Index and on the same layer
  • Tried to Debug.Log() if there's any collision (there isn't)
  • Made sure I'm using OnCollisionEnter2D on the boss' health script
  • Compared the syntax I use with another collision (where the player collides with an object and dies - this works perfectly fine).

However, none of these seem to be working.
This is the boss' health script:

void OnCollisionEnter2D (Collision2D coll)
{
    Debug.Log("COLLIDED");
    bosshealth -= 1;
}

Here is the projectile prefab:
projectile prefab
And the boss prefab:
boss prefab

Does anyone have a clue as to why they're not colliding? the projectile just glides over the boss

EDIT: I found a temporary fix! Disabling the Kinematics of the boss allows for both objects to collide, and successfully display a debug message! Just a problem though; I don't want the boss to freely float around in space. I use the kinematic to ensure it stays put at all times until told to by scripts.

Is there a way to get around not having to disable the kinematics?

davidpox
  • 31
  • 1
  • 8