Collision extents for TileMap not where they should be when I run game!

arezekielarezekiel Posts: 4Member
edited July 13 in 2D

I just can't figure it out, I must be overlooking something. It has something to do with the TileMap, still don't know why it's doing what it's doing. Collision extents not where they should be when I run the game.... Please take a look at my project, and let me know what is going on here. Thank you!


Tags :

Comments

  • arezekielarezekiel Posts: 4Member
    edited July 13


  • arezekielarezekiel Posts: 4Member

    Still can't figure out why it's working the way it is, but I found a work-around...

  • TwistedTwiglegTwistedTwigleg Posts: 1,298Admin

    Are the collision shape nodes scaled? That might be causing the problem, as Tilemap nodes (to the best of my knowledge) reset the tile size to a scale of 1.

    I’ll try to take a look at the project soon and see if I can figure out what is causing it to behave strangely.

    (Side note: Welcome to the forums)

  • MegalomaniakMegalomaniak Posts: 1,273Admin

    https://github.com/godotengine/godot/issues/3503

    It looks like you are using godot version 3.0.x I recommend you try making a duplicate of your project and opening it in 3.1

  • TwistedTwiglegTwistedTwigleg Posts: 1,298Admin
    edited July 14

    I downloaded the project and found the issue: In jungle_dirt_tileset the StaticBody2D and CollisionShape nodes are scaled, which is causing the problem. It seems the CollisionShape2D scale isn't causing an issue (surprisingly), however the StaticBody2D scale is being reset to a scale of 1 when used with the Tileset, which is leading to the large collision shape margins you are seeing.

    The fix is thankfully simple: Just set the scale of the StaticBody2D nodes back to 1 and adjust the collision shape nodes as needed. Personally, I'd reset the CollisionShape2D node scales and just change the Extents property of the RectangleShape to X:16 Y:16 just to be on the safe side.

    With those fixes, the collision should work as expected:

    Edit: I forgot to mention I was using Godot 3.1.1, which may have helped. The Tile set scene still needed adjusting, but updating may have helped.

  • arezekielarezekiel Posts: 4Member
    edited July 14
    Right on. Thank you guys for the help! Yeah, that's pretty much what I did. For whatever reason after trying a significant number of adjustments in 3.0, I wound up centering the sprite to make sure it lined up, then scaling the staticbody to 0.5, and change the collisionshape extents to 16 by 16. I know there should be a simpler method, but they are where they should be now so I don't want to mess with it. Lol!
    Anyways, thank you again! I appreciate it.
    
Sign In or Register to comment.