0 votes

So in my intro, I have a stick come in and draw in the dirt (tile map). I used the AnimationPlayer node as a child of the Sprite node for the stick and it comes in and out exactly how I want it to. But I have no idea how to put the tile for the darker dirt path made by the stick that would follow behind it. I tried having the tile as a Sprite attached to AnimationPlayer as well, but 1) it was like 30 different Sprites so that should appear one by one in the key frames as I needed them to behind the stick and 2) that wouldn't even work because all of the tile sprites stayed visible throughout the whole animation, even at the beginning where they had no key frame. Either that, or the sprite just follows the stick around instead of staying in its location on the scene.

There has to be an easier way to just plop things into the animation? Is there a way I can draw it on a separate TileMap node and reveal it slowly through the animation?

Thanks for any pointers in advance

asked Jun 4 in Engine by megsmarie (12 points)

1 Answer

0 votes

I don't understand very well how the implementation is but there are several ways, Tilemap has several functions, including creating an ingame tile, example:

$ TileMap.set_cellv (tilemap.world_to_map (get_global_mouse_position ()), 0)

In this example I use the mouse position to create tiles while I move it, look at the world_to_map (Vector2) function, what it does is pass the world coordinates (Increase by one for each pixel) to the tilemap coordinates (increase by one by each tile). The integer at the end indicates the tile id, which are unique for each tile in the tilemap. Using -1 removes the tile in position. If there is another tile already drawn it is replaced.

What I would do is include a Position2D node as the child of your animated sprite (or use the sprite position), at the tip where it draws. Then I would use its position (Your global position) in the set_cellv () function to draw the tiles as it moves. Example pseudocode:

func _process:
   if animation_is_start:
      $TileMap.set_cellv ( $TileMap.world_to_map($Sprite/Tip.global_position), 0)
answered Jun 4 by estebanmolca (1,199 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.