So I built a map in tiled and I added the the tile collision tilesets to the map but for some reason when I I run the game in unity the collision detection just doesn’t work at all. I get this message stating the collider did not create any collision shapes as they all failed verification. I can send the build over If you need me to, I just need help.
Does the TMX loader you are using actually support loading the collision information from Tiled/TMX? Many loaders just don’t do that because it’s a relatively new feature.
It sounds like you’re using Tiled2Unity. In that case let’s hope @Seanba can help you.
If you’re using Tiled2Unity I can provide some pointers.
I’ve seen collision shapes fail verification when the vertices are packed in too close together or if the collision shape is made up of too many vertices. Are you using “Snap To Grid” or “Snap To Fine Grid” when creating collision geometry in the Tiled Collision Editor? I find many newcomers to Tiled create polygons haphazardly not realizing their polygon cooridinates are in floating point (sub-pixel) values.
Hey Thanks for the response! I am using Tiled2Unity but I did not use the Snap to Grid or Snap to Fine Grid feature. I imported a red box tile I created and used that as the collision tile. Then I opened up the collision editor in tiled and placed the tiles on top of the assets I wanted the character to collide into. I’ll try out the Snap to Grid feature and will let you know if I need further assistance, Thanks a bunch!
Thanks for the reponse
It’s not budging. Would you kindly take a look at it to see what’s going on with it? I can just export the package and send you the dropbox link via email.
If you send it me I’ll take a look. You can get my email from my blog where you downloads Tiled2Unity from.
Edit to add: Might be a good idea to send me your Tiled (*.tmx) file and associated textures just in case it’s something with the way the Tiled map is authored.
will do thanks.
Thanks to @Seanba I finally got it! It was actually a simple fix. All the collision data was transferring to unity through tiled to unity but I didn’t set up a box collider around my character. The character is now colliding with the tiles and everything is running smoothly, THANKS!
What do you mean “set up box collider around character”? Ive been trying for weeks to get this to work.
Hi Chase, if you could be a bit specific about what you’re seeing and what’s not working for you I’m sure we can provide some direction. Does your exported prefab have colliders on it? Do your sprites? Do you have a rigid body on your sprite?
You may also want to look at some examples I’ve made. They have sprites colliding with geometry and come with all Tiled and source files. They may go a long way to helping you figure out what you’re missing.
What Markeus is talking about is that his sprite needed a collider on it that would collide with the colliders on the level he exported from Tiled2Unity into his Unity project. Does that make sense?
Post a couple of screenshots of what exactly you’re having issues with. I’m sure its going to be the simple fix I had to implement.
How were you able to get the polygon collider 2d to go around the objects set to be a collider? In the tiled editor, I’ve set the tile I’m using as a collier to be an obstacle using view>tile collision editor. I then selected the map and exported it.
Edit:
I added my collisions after my first export, and didn’t reload the prefab so the scene wasn’t up to date. All is well.
Glad you got it working, Chase. I’ve been burned by prefabs before as well. I think they will always be automatically reloaded unless you make an edit to them in your scene hierarchy. FWIW, I encourage the use the Custom Importers so that you never have to edit a prefab by hand.
Have a great 2016.
I hate to necropost, but I’m still having some problems.
Granted, new to Unity and Tiled/T2U, but I thought I understood fairly well.
I definitely put the collisions, but for some reason, it seems they aren’t working for me either.
My character has a Rigidbody and Box Collider, but I still go through the colliders that were loaded in by T2U from the original map.
What about colliders that are not loaded by Tiled2Unity? I’d try to simplify the problem as much as possible with your character and perhaps a box or polygon collider that you placed in your scene by hand. That way you can get general help from the Unity forums if you’re still stuck. (Collision problems are very common and Unity forums are well equipped to offer advice.)
Fair enough, you’re on to something.
I toyed around some and it seems it has something to do with my movement script, as when disabling the kinematic nature of a sprite, I can FALL onto a collision, but I still move through them.
Would you happen to know off the top of your head where to point me (or do you know this to be a common problem and know how to fix it), because I’m a bit unsure of what exactly I need to alter to make it all cooperate?
Well, I’m silly.
I didn’t notice the COLLISION DETECTION PART of the Rigidbody.
I am derplord.
Alright, mostly great now, though I’m still a bit confused of where to go now, since now I can still make myself move into the collision zones, or go through them. I suspect this is due to my move script, since I move a set amount at a time, which might make me go through the collisions (or try to – I definitely face resistance now).
Any ideas or anyone know exactly what to do?
Hi DCoward, our host is pretty cool but this is a Unity issue and not really related to Tiled so we should move the discussion onto the Unity forums.
But while I have you, if your code is moving your character around by setting their position then that could be the problem. The character controllers normally have a “Move” function that properly checks against collisions.