0
\$\begingroup\$

so my code on my collider is as followed

public class Collide : MonoBehaviour
{

    private void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("Collision");
    }
}

the projectile has a rigidbody2D and a capsule Collider 2D.

collider has a box collider 2D.

the projectile spawns from my player and moves upwards in the direction of the collider (the collider is large enough that the projectile cant miss it).

the projectile however goes straight through the collider and no message appears and I have no idea why.

what I've tried and made sure of :

  • both are on the same layer and plane(z axis)
  • gave the collider a rigidbody but changed nothing
  • made the collider on trigger and not on trigger
  • made the projectile dynamic and kinematic
  • changed collider script to onCollisionEnter and onCollisionEnter2D
\$\endgroup\$
  • 2
    \$\begingroup\$ Hi ! Have you checked in your collision matrix in Physics if both game objects layers can collide ? \$\endgroup\$ – Sebastien Servouze Jan 7 at 13:15
  • \$\begingroup\$ What framework are you using? If that is java, I would reccomend switching to python cause there isba larger game development communkty over there \$\endgroup\$ – MrWickerWeaver Jun 7 at 17:56
0
\$\begingroup\$

As stated nu Sebastien Servouze I reallised after some searching arround that there is indeed a collision array matrix, which solved my issue.

\$\endgroup\$
  • 1
    \$\begingroup\$ If the issue is solved, make sure to mark your answer as correct, so others don't have to spend time answering. \$\endgroup\$ – TomTsagk Feb 8 at 16:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.