This is the testing Godot forums! All forum posts unique to this forum will be deleted! Please use the main forums here for any posts you want to keep. All forum rules still apply.

My tilemap is not keeping its collision

TcheyTchey Posts: 52Member

Hello,

I have a land.xscn with 5 nodes like this, all with unique name.

StaticBody2D
--Sprite
--CollisionShape2D (RectangleShape2D the size of the grid, 32x32)

They are simple 32x32 pixel, nothing fancy.

Then i go to Scene/Convert to... TileSet and save it as land.xml

I go to my garden.xscn and add a TileMap to my Node2D, set land.xml, then i place a few elements, save, check debug to show collision, and see that there is not.

My player has a CollisionShape2D too (a circle in the 32x32 size of the player) and it works well to enter an Area2D to go from garden to house for example, and i can see it in debug mode, so i assume its collision is fine.

What did i miss ?

Thanks for reading

Best Answer

Answers

  • PaulMurrayPaulMurray Posts: 26Member

    How is your player constructed? Is it a RigidBody2D type?

  • TcheyTchey Posts: 52Member

    My player is :

    Player (a KinematicBody2D)
    -- Sprite
    -- AnimationPlayer (a basic loop always active in 4 frames)
    -- Light2D
    -- CollisionShape2D (circle inside the grid size)

    But i think the problem is from the tileset, as the debug mode doesn't show the collision for the "land", only the player

  • PaulMurrayPaulMurray Posts: 26Member
    Accepted Answer

    Try creating your tiles like this;

    Sprite

      • StaticBody2D
          • Collision2D

    I tried to use a StaticBody as the parent as per your example and couldn't even get the tiles to load. This is the method demonstrated in the docs - http://docs.godotengine.org/en/stable/tutorials/2d/using_tilemaps.html

  • TcheyTchey Posts: 52Member

    Sprite

      • StaticBody2D
          • Collision2D

    is working indeed. Counter intuitive i think.

    Thank you !

    Now i need to find out why my player is stuck on collision (cannot move at all)...

  • PaulMurrayPaulMurray Posts: 26Member
    edited October 2016

    Have you set the RigidBody2D mode of the player to 'Character'? in the Godot inspector?

  • TcheyTchey Posts: 52Member

    I can't get what you mean. I checked 10 times the options in the Inspector for all the parts of my player, and nothing is like that. I missed something ?

    Player (a KinematicBody2D)
    -- Sprite
    -- AnimationPlayer (a basic loop always active in 4 frames)
    -- Light2D
    -- CollisionShape2D (circle inside the grid size)

  • PaulMurrayPaulMurray Posts: 26Member

    Never mind, I thought your player was a RigidBody2D, not Kinematic, hence why you won't see those options. Are you positioning your player above the tilesmap X position, there's no chance the collision boxes are overlapping when the game runs?

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.