Тёмный

How to use and adjust 2D collider in Unity 

Подписаться
Просмотров 55 тыс.
% 1 206

In this video we will talk about how to adjust the shape of a 2d collider in Unity.
Tilemaps in Unity allows us to quickly design levels for our games. The problem is usually with the colliders that our tiles generate. The automatically created collider doesn't always matches what we had in mind. Lucky for us there is a simple way to tweak it. Let me show you how in this video 😉
Assets used:
adamatomic.itch.io/jawbreaker
cainos.itch.io/pixel-art-top-down-basic
trevor-pupkin.itch.io/tech-dungeon-roguelite
My longer video courses teaching how to make 2D games in Unity :
courses.sunnyvalleystudio.com/
Tilemap collider 2d doc:
docs.unity3d.com/Manual/class-TilemapCollider2D.html
docs.unity3d.com/Manual/class-CompositeCollider2D.html
docs.unity3d.com/ScriptReference/Tilemaps.Tile.ColliderType.html
Join the discord:
discord.gg/RQEtYHz
You can support me through Patreon:
www.patreon.com/sunnyvalleystudio
00:00 Introduction
00:35 Installing tilemaps
02:27 Preparing tilemap for colliders
03:06 Tilemap Collider 2D
04:35 Composite Collider 2D
06:26 More complex tilemap
07:41 Problem - Collider doesn't fit
08:06 Tile Collider type
09:00 Adjusting collider shape
12:30 Learn how to make 2d games in Unity
#tilemaps #unity2d #gamedev #sunnyvalleystudio

Опубликовано:

 

22 ноя 2021

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 96   
@OssyAndarii
@OssyAndarii 2 года назад
Man, I am so glad you made this tutorial, I was trying to find a way to adjust the spikes colliders in my game but I couldn't find any helpful videos. Thanks a lot and keep the good work!
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
I'm glad that my video has helped you :) Thanks for watching!
@Jamie_Gamedev
@Jamie_Gamedev 2 года назад
Wish I knew about custom physic sizes when started last project 🤦🏻‍♂️. Amazing video as always!
@ghostev
@ghostev 2 года назад
Thanks alot, I didn't know the physics shape in the sprite editor; it's just what I needed :)
@YS_Yousef
@YS_Yousef Год назад
كيفك يسطا
@tPlayerioT
@tPlayerioT Год назад
thanks. This helped me, im just having a issue with the collider sometimes ignoring the player collider but eventually i will find out the issue.
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Glad to hear that!
@oguzhanaydn7482
@oguzhanaydn7482 Год назад
thanks for the adjust part, i couldn't find it anywhere else
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Glad it helpse!
@HenryJamesSuarez
@HenryJamesSuarez 16 дней назад
this is what I'm looking for. thank uuuuuu
@SunnyValleyStudio
@SunnyValleyStudio 14 дней назад
Glad I could help!
@alfrogiguess
@alfrogiguess Год назад
Thx man! Was getting caught on diagonal tiles and you rlly helped
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Glad I could help! 👍
@thrashspeed007
@thrashspeed007 Год назад
The only tutorial that really solved my problem, im so grateful, thanks!!
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Glad it helped 🙂
@Hiroki_MakeGames
@Hiroki_MakeGames 8 месяцев назад
Nice tutorial! Thanks! Now i'm trying to figure out how to make the top part of the trees and bushes with no collision .
@SunnyValleyStudio
@SunnyValleyStudio 7 месяцев назад
You can always create your colliders as separate Tilemap and instead of using tree tile as collision shape use something else. In general think about layering multiple tilemaps together.
@dreaman7325
@dreaman7325 2 года назад
now this is really an amzaing tutorial! i learned so much, thanks a lot! i would love to see the next video about the layer problem you showed at the end 🙏
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Thanks. The next video was meant to be a video version of my older blog post (some people preferer watching to reading). Here it is: www.sunnyvalleystudio.com/blog/how-to-sort-sprites-in-unity
@dreaman7325
@dreaman7325 2 года назад
@@SunnyValleyStudio this is absolutely great! thank you :)
@jonathanmaywood4568
@jonathanmaywood4568 2 года назад
Great tutorial, I didn't know about the physics shape in sprite editor.... helps a lot with one way platforms!
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Glad it helped! Thanks for watching 🙂
@fernzilio6087
@fernzilio6087 Год назад
Nice tutorial
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Thanks 👍
@denisgoodman4492
@denisgoodman4492 Год назад
Great tutorial, it's a very useful information. Thanks
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Thanks for watching! 🙂
@Tankwiper
@Tankwiper 2 года назад
Very good tutorial. I didn't know such features exist.
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Thanks for watching!
@ChaosEater39
@ChaosEater39 6 месяцев назад
this is such a useful tutorial! it is exactly what I was looking for. thanks :)
@SunnyValleyStudio
@SunnyValleyStudio 6 месяцев назад
I'm glad to hear that 🙂
@idangomberg2750
@idangomberg2750 Год назад
Thank you!
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Thanks for watching 🙂
@yakuperoglu5162
@yakuperoglu5162 Год назад
thanks so much bro you are a life saver thx again
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Glad to hear it!
@credormk5770
@credormk5770 2 года назад
This video really help me, thanks!
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Glad it helped! Thanks for watching!
@MatthewTaylor86
@MatthewTaylor86 2 года назад
An excellent video - got me subbed, thanks!
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Thanks for watching!
@vadim700230
@vadim700230 2 года назад
big thanks you man
@0truer
@0truer 2 года назад
Thanks! When the boxes were seperate the player kept getting stuck behind really thin invisible walls, but they dssapeared after adding a compsite collider.
@KonigTheV
@KonigTheV 2 года назад
The Beginn was bad, but the it was a great Tutorial. Good Job
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Thanks for the feedback!
@Myzzz12
@Myzzz12 2 года назад
Excelent work!
@32kgold37
@32kgold37 2 года назад
Thanks you!
@elmarinerito3197
@elmarinerito3197 Год назад
teamo, eres un tipazo! muchas gracias
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Thanks for watching! 👍
@redspill0738
@redspill0738 2 года назад
thank you
@sten360
@sten360 2 года назад
Hey, are you still planning to release part 2? The collision and render order based on the direction the player is approaching from is what's been a pain in my side with unity tilemaps for the longest time. Really looking forward to seeing how you solved that!
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Hey! Thanks for the feedback! I will be sure to plan this tutorial soon. I have a blog post about this issue based on which I will make a video so maybe it will help you: www.sunnyvalleystudio.com/blog/how-to-sort-sprites-in-unity
@danielegargiulo2051
@danielegargiulo2051 2 года назад
@@SunnyValleyStudio Please make a video about this topic. I'm struggling to dynamically display a character on top or below a tilemap tile based on the character Y position.
@ultimatesin3544
@ultimatesin3544 2 года назад
@@SunnyValleyStudio Yes me too please make second video if you can thanks for your help
@marcoschedid4033
@marcoschedid4033 Год назад
@Sunny Valley Studio The video was awesome and so the blog post, but please make a video about it, there's no sorta thing on youtube gamedev comunity and will be helpful for a lot of people
@alexthompson8977
@alexthompson8977 Год назад
@@SunnyValleyStudio for some reason the colliders aren't changing to the custom physics shape I made for some of them :/
@youranonymousyoutuber4051
@youranonymousyoutuber4051 Год назад
thanks a lot man
@SunnyValleyStudio
@SunnyValleyStudio Год назад
You're welcome!
@travh98_
@travh98_ 2 года назад
Thank you, I love you
@PvPNetwork
@PvPNetwork 11 месяцев назад
Great video. Small thing incase anyone else have this issue. I had to Remove: Composite Collider 2D Rigidbody2D Tilemap Collider2D to force a regeneration of the collider after editing the sprites Physical Shape. Disabling and reenabling the component didn't work for me.
@SunnyValleyStudio
@SunnyValleyStudio 11 месяцев назад
Thanks for letting me know 👍
@HitsquadTTV
@HitsquadTTV 2 года назад
thx this helped me out a lot!!! :3
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Thanks for watching! 🙂
@gopichandde
@gopichandde 2 года назад
Very Informative Video🎉
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Thanks a lot for watching!
@PK-se2jh
@PK-se2jh 2 года назад
thankyou :)
@itaisinger1360
@itaisinger1360 2 года назад
nice video
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Thanks for watching!
@mohokhachai
@mohokhachai 8 месяцев назад
@SunnyValleyStudio
@SunnyValleyStudio 8 месяцев назад
Thanks for watching!
@MagnusRazer
@MagnusRazer Год назад
No entiendo el ingles, pero si que entendi como resolver mi problema, Gracias Peter Griffin
@JonelKingas
@JonelKingas 8 месяцев назад
not working idk why, wahtever i do custom physics shape not working
@SunnyValleyStudio
@SunnyValleyStudio 8 месяцев назад
Strange. Which Unity version are you using? Maybe they have changed something. Feel free to join our discord (discord.gg/RQEtYHz) and let me know since I can sometimes forget to answer comments 🙂
@JonelKingas
@JonelKingas 8 месяцев назад
@@SunnyValleyStudio It works now, i had to update aseprite importer, it worked on PNG files but not aseprite files, cause I did some research and found out only recently that there was a new version that turned on custom physics shape support on it.
@KaidenXIII
@KaidenXIII 2 года назад
Hey, great video once again ! Is it possible to request a tutorial somehow ? :D
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Hey! Join the discord discord.gg/RQEtYHz there is a suggestion channel where you can let me know what interest you :)
@zapleaf
@zapleaf 2 года назад
THANK YOU
@triple3204
@triple3204 Год назад
When I go into wireframe mode it does not show up and then you walk through the tile map thing that I made
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Do you have Gizmos toggle on? It is the first icon on the top right of the scene view. Here is more info about it docs.unity3d.com/Manual/GizmosMenu.html
@triple3204
@triple3204 Год назад
Thank you! It works now :)
@MarkWaner
@MarkWaner Год назад
But what if stairs were 3 tiles wide? Can we make it so that some sprites do not generate a collider?
@SunnyValleyStudio
@SunnyValleyStudio Год назад
If you don't add a tilemap collider or make a secondary tilemap with no collider you will have stairs that don't collide with anything.
@gambit1637
@gambit1637 2 года назад
I tried to use Composite Collider and it didnt collide at all, only top and bottom was added to collision. So i stayed in Collider 2D.
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Hey! It is just for the purpose of optimization. Check out the documentation to learn more about it docs.unity3d.com/Manual/class-CompositeCollider2D.html
@academiadoscoins9034
@academiadoscoins9034 Год назад
Help me friend! I'm going crazy with the collisions in Tilemap. I have a cannon that shoots a bullet at the walls of a tilemap. The bullet bounces like a pool table. But the collison.transform.position and then the tilemap.WorldToCell(position) gives me the cell in the wrong grid. It doesn't return the cell where the collision occurred. I can even change the Vector3Int, but in collisions in the corner (diagonal) it does not return the correct tile.
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Maybe this can help discussions.unity.com/t/how-to-detect-on-which-exact-tile-a-collision-happened/216779
@academiadoscoins9034
@academiadoscoins9034 Год назад
It didn't. Actually the forum answer is incomplete and doesn't have any examples
@Gendon-
@Gendon- 2 года назад
I can't remove collider from sprite editor, how to remove it?
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
I am pretty sure that you can select each point and click DELETE or there might be in the top options / parameters bar to add / remove colliders.
@jackpp8337
@jackpp8337 2 года назад
if player Near the wall foot , the bullet gets caught in the wall .How do you fix that
@SunnyValleyStudio
@SunnyValleyStudio 2 года назад
Hey! I am not certain if I understand correctly but basic solution is always to tweak things until they work together. You bullet can have a separate smaller collider to collide with walls or I guess your wall can have a smaller collider (although its a lot of work). screenshots
@holyclasher
@holyclasher Год назад
When trying to add a point in the sprite editor to make a new corner it doesn't let me and the blue square just continues to hover around
@SunnyValleyStudio
@SunnyValleyStudio Год назад
Strange. I haven't encountered something like this before - well only when I was in a play mode and tried to modify something.
@holyclasher
@holyclasher Год назад
@@SunnyValleyStudio I checked online and I think it may be a problem with the unity version 2022.3.4f1
@cartermichaud9467
@cartermichaud9467 Год назад
Getting this bug too! Super annoying!
@theoingledew4031
@theoingledew4031 Год назад
Same super frustrating
@cartermichaud9467
@cartermichaud9467 Год назад
@@theoingledew4031 I updated to Unity 2023.1.6f and the issue went away
@hungnguyentuan9590
@hungnguyentuan9590 6 месяцев назад
i cant creat a new blue square
@SunnyValleyStudio
@SunnyValleyStudio 6 месяцев назад
You mean in the "custom Physics Shape" menu? Maybe there is something about it in the documentation docs.unity3d.com/Manual/CustomPhysicsShape.html ?