Problem with One-Way Collision in Tilemap

BinaryOrangeBinaryOrange Posts: 234Member
edited August 2016 in 2D
This has been quite the head-scratcher all day for me. <br /><br />In following the Kinematic2D character example, I decided to try my hand at creating one-way collision for my platforms.  For some reason, it doesn't work. <br /><br />I have created my tileset so that the top most tiles have one-way collision.  I created a KinematicBody2D node, which is a parent to a Sprite node and a Collisionshape2D node.  The structure looks like this:<br />left_structurepng<br /><br />The properties of the KinematicBody2D node look like this:<br />right_statspng<br /><br />I chose 16 for the Max Depth, as the CollisionShape2D is approximately 16px high.  I have a sneaking suspicion the problem is with the Max Depth variable.  <br /><br />I really hope that it isn't impossible to do this with TileMaps, surely this should work?<br /><br />I even tried doing Direction 0,-1, but that does nothing, which makes sense as I'm certain that would make it that I would bump my head on the bottom of the tile instead of passing through, which is my ultimate goal.  I want to make it so that each tile can have jump-through abilities, just like a lot of other platformers out there!<br /><br />If anyone could help me out, or give me some advice, that would be great!<br /><br />EDIT: Okay, I think I have come to the conclusion that for some reason, Tilemap scenes won't save the data necessary to allow one-way collisions. <br /><br />So, in order to solve my problem what I did is this!<br /><br />In my main_scene.scn, I just created an empty Node, and then created several empty CollisionShape2D nodes as well. I then made that node a child of the Tilemap:<br /><br />onewaycollisionpng<br /><br />So, my scene looks like this currently:<br />levelpng<br /><br /><br />This is a solution that will work well for now, but it does take a lot of time to create the nodes and size them appropriately.  However, it makes me happy as I have one-way collision implemented in a working fashion!<br /><br /><br />
Tagged:

Tags :
Sign In or Register to comment.