#Godot can I somehow have a signal emitted once a certain node (Player Character) is on or just passed a specific location? Or is there another built-in method to check whether something just passed a specific point in space?#gamedev
-
-
dbat :godot: (Viva Ukraine)replied to Natasha Nox πΊπ¦π΅πΈ last edited by
@Natanox Other than Areas (2d, 3d) I would say you'd need to constantly cmp pos player to pos thing.
-
dbat :godot: (Viva Ukraine)replied to dbat :godot: (Viva Ukraine) last edited by
@Natanox Or maybe colliders.
-
Hemera :nixos: :ms_snow_leopard:replied to dbat :godot: (Viva Ukraine) last edited by
-
Natasha Nox πΊπ¦π΅πΈreplied to dbat :godot: (Viva Ukraine) last edited by
@dbat That sounds like a solid idea. I want it to change direction once reaching the center of the next tile it moves to, so once the player presses a key I could spawn a temporary collider in the tile the character is *not* meant to enter anymore since the snakes head is the same size as one tile, so once it fully reaches the last tile before the collider the movement is executed.
-
Natasha Nox πΊπ¦π΅πΈreplied to Hemera :nixos: :ms_snow_leopard: last edited by
@Hemera @dbat Mmh, that might causes offset problems though. I want the snakes head to change direction once being in the center of one tile. Of course I could use that signal on the tile it's *not* supposed to enter anymore and have it "snap back" to the grid to make sure the player isn't slowly moving off-center.
-
Luke Millerreplied to Natasha Nox πΊπ¦π΅πΈ last edited by
-
Natasha Nox πΊπ¦π΅πΈreplied to Luke Miller last edited by
@upmultimedia @dbat I'm using a TileMapLayer for the playing area. With masks, do you mean the different collision "slots" (by default I think there are 8?). It was my intend to use those.
This is my learning project right now so please feel free to point to something in case I'm missing the obvious in one way or another.
-
crypticceleryreplied to Natasha Nox πΊπ¦π΅πΈ last edited by
@Natanox @Hemera @dbat maybe in that case, you can place an area at the current snake head position and have the action performed once the specific head shape (if the snake consists of multiple shapes) leaves it. https://docs.godotengine.org/en/stable/classes/class_area2d.html#class-area2d-signal-body-shape-exited
But this only works if you know this one tile in advance (or you have spawned a smaller than one tile area).
Not sure if this is understandable. I can sketch the idea if it would help. -
Natasha Nox πΊπ¦π΅πΈreplied to crypticcelery last edited by
@crypticcelery @Hemera @dbat Ooh, those functions are perfect! Thank you!