Unity 5 2D collisions

Started by
6 comments, last by skmongol 8 years, 8 months ago

Does anyone have a guide on how to make collisions with Unity 5 2d? I know how to make the collisions in Tiled but I do not know how to get them to work in Unity. I'm talking about basic collisions with objects that won't allow the player to walk through/over them.

Advertisement

I doubt I'm understanding your question properly, I've been using Unity for a grand total of 2 days.

I've got a player and 2 enemies set up so that they walk into each other instead of through each other and that was just done by doing:

AddComponent->Physics2D->ColliderType (choose the shape of your collider).

Do this for each of your objects.

I doubt I'm understanding your question properly, I've been using Unity for a grand total of 2 days.

I've got a player and 2 enemies set up so that they walk into each other instead of through each other and that was just done by doing:

AddComponent->Physics2D->ColliderType (choose the shape of your collider).

Do this for each of your objects.

I've tried this and it doesn't seem to work for my collider objects. Maybe I am missing something?

Hi!

I think that one of your GameObjects (normally the player) need to have a Rigidbody2D.

Try AddComponent->Physics2D->Rigidbody2D to your player.

Regards.

Hi!

I think that one of your GameObjects (normally the player) need to have a Rigidbody2D.

Try AddComponent->Physics2D->Rigidbody2D to your player.

Regards.

this makes my player fall off of the map for some reason unless I check "Is kinematic". I added the 2d rigidbody to my player and box colliders to my collider objects but they don't seem to work either.

It will fall off the map due to gravity (enabled when you set a 2d rigidbody).

2d works in x and y axis, x is left and right, y is up and down, gravity is positive y (I think).

If you are doing a top down game you can set gravity scale to 0 and it will no longer fall.

If you're doing a side-scroller you'll need to find out why it isn't colliding with whatever you are using with the floor, are you sure they both have 2d colliders on them and at least one of them is a 2d rigidbody?

It will fall off the map due to gravity (enabled when you set a 2d rigidbody).

2d works in x and y axis, x is left and right, y is up and down, gravity is positive y (I think).

If you are doing a top down game you can set gravity scale to 0 and it will no longer fall.

If you're doing a side-scroller you'll need to find out why it isn't colliding with whatever you are using with the floor, are you sure they both have 2d colliders on them and at least one of them is a 2d rigidbody?

The player is set as a 2d rigid body and my colliders are set with 2d box colliders. I made the colliders in Tiled and then imported them into Unity and they still retained their polygon colliders but they aren't working for some reason. Do I have to code them in?

I figured it out. Had to add rigid body to both player and collision objects.

This topic is closed to new replies.

Advertisement