• Advertisement
Sign in to follow this  

Unity Unity 5 2D collisions

This topic is 979 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Edited by WASDMagician

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

Hi!

 

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

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

 

Regards.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement