Hi there, I’m having the following issue, with a video to illustrate. For some reason the character I’m working on (the bat-like one) only collides with the ghost-like and doesn’t collide neither with the player character nor with a copy of itself. All three characters have the same layer (which collides with itself), are all untagged and have rigidbodies with frozen movement and rotation (which for some reason seems to be relevant for collisions or at least triggers). For the collision check and printing I’m simply using this:
void OnCollisionEnter2D(Collision2D c)
Video with issue: - YouTube
For Collision both the GameObect Must be a RIgidbody and one GameObject must have a Collider component in it and attach the script on the GameObject in which you want to detect the collision.
private void OnCollisionEnter2D(Collision2D collision)
if (collision.gameObject.name == "GIVE THE GAMEOBJECT NAME")
Found the issue, the rigidbody was kinematic. Not sure how it works but for some reason that seems to be a problem. Thanks anyways.
Ensure the following things are considered in your code,
- All gameobject should contain
collider attached and the player
gameobject should contain the
rigidbody component in it.
- The collider size should change to
the width and height of the
component instead of default (1,1)
- Uncheck isKinematic option in Rigidbody component if it’s selected.