Collision detection not working in Unity 2D

Jean Finley

I have two 2D game objects. They each have a Box Collider 2D and a Rigid Body 2D which is not kinematic. When the game plays, one moves towards the other and collides with it.

However, I also have the following method in the moving GameObject:

void OnCollisionEnter(Collision collision) 
{
    print( "Collided with someone" );
}

The print statement never prints, so presumably the method is never called. Where am I going wrong?

T. Kiley

Unity has replicated all of the physics methods for 2D with the word "2D" stuck onto the end! So for your example, it should be changed to:

void OnCollisionEnter2D(Collision2D collision)

And the same with basically any other 2D physics thing.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Unity 2d collision detection not registering

From Dev

Unity 2D Collision Detection

From Dev

2D Collision detection not working

From Dev

2D Per pixel collision detection not working

From Dev

Collision Detection in Java 2D Not Working Properly

From Dev

Are There Alternatives to Collision Detection in Unity3D?

From Java

Collision detection in pygame not working

From Dev

Collision detection not working?

From Dev

How can I make custom 2D polygon in Unity with collision detection?

From Dev

Collision detection in java 2d game

From Dev

Trouble with java 2D collision detection

From Dev

PyGame border collision detection not working

From Dev

Pygame Jumper collision detection not working

From Dev

Collision Detection on 2 objects

From Dev

Collision Detection Javascript Not Working(rather Im not working)

From Dev

Collision Detection for fast moving game object in Unity

From Dev

HTML Canvas game: 2D collision detection

From Dev

What is the logic behind collision detection in 2d games?

From Dev

Collision detection in a 2D maze with thick walls

From Dev

Collision detection in 2D game without tiles XNA

From Dev

2D Monogame: Rectangle collision detection, side specific

From Dev

Issue with Collision Detection in Pygame for simple 2D Platformer

From Dev

Collision Detection with Ceramic Tile Engine & Box 2D

From Dev

Collision detection in 2D game without tiles XNA

From Dev

How to react on collision detection in 2d platformers

From Dev

2D Monogame: Rectangle collision detection, side specific

From Dev

Collision Detection hitTestObject not working.. ish

From Dev

JavaScript Collision Detection doesn't seem to be working?

From Dev

Collision detection not working for adding 1 to score

Related Related

  1. 1

    Unity 2d collision detection not registering

  2. 2

    Unity 2D Collision Detection

  3. 3

    2D Collision detection not working

  4. 4

    2D Per pixel collision detection not working

  5. 5

    Collision Detection in Java 2D Not Working Properly

  6. 6

    Are There Alternatives to Collision Detection in Unity3D?

  7. 7

    Collision detection in pygame not working

  8. 8

    Collision detection not working?

  9. 9

    How can I make custom 2D polygon in Unity with collision detection?

  10. 10

    Collision detection in java 2d game

  11. 11

    Trouble with java 2D collision detection

  12. 12

    PyGame border collision detection not working

  13. 13

    Pygame Jumper collision detection not working

  14. 14

    Collision Detection on 2 objects

  15. 15

    Collision Detection Javascript Not Working(rather Im not working)

  16. 16

    Collision Detection for fast moving game object in Unity

  17. 17

    HTML Canvas game: 2D collision detection

  18. 18

    What is the logic behind collision detection in 2d games?

  19. 19

    Collision detection in a 2D maze with thick walls

  20. 20

    Collision detection in 2D game without tiles XNA

  21. 21

    2D Monogame: Rectangle collision detection, side specific

  22. 22

    Issue with Collision Detection in Pygame for simple 2D Platformer

  23. 23

    Collision Detection with Ceramic Tile Engine & Box 2D

  24. 24

    Collision detection in 2D game without tiles XNA

  25. 25

    How to react on collision detection in 2d platformers

  26. 26

    2D Monogame: Rectangle collision detection, side specific

  27. 27

    Collision Detection hitTestObject not working.. ish

  28. 28

    JavaScript Collision Detection doesn't seem to be working?

  29. 29

    Collision detection not working for adding 1 to score

HotTag

Archive