I am completely new to Unity, and trying to learn how collision system works. Unfortunately in my case, it is not working :).
I have a basic 2D game layout and two objects. One is a player game object with Rigidbody2D component attached to it, the second one is a basic cube, with box collider and is trigger → checked on.
Now I simply want to check the collision between these two so part of my player script for collision looks like this:
However it does nothing. Is there anything else I need to do? It looks to me like something is not set-up properly in the inspector. (both objects have position o Z axis set to: 0 - is this correct?)
Hello Michal,
Did you remember to add also a collider component to your players game object? In order for the collison to work, you will need a collider on both, your player and the cube.
Also make sure, that you are using 2D colliders (e.g. BoxCollider2D and not BoxCollider), otherwise OnTriggerEnter2D will not be invoked