You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func _physics_process(delta):
print($RayCast2D.is_colliding())
if Input.is_action_just_pressed("ui_right"):
print("Changing to different tile")
$TileMap.set_cell(1, 0, 1)
$TileMap.update_dirty_quadrants()
$RayCast2D.force_raycast_update()
print($RayCast2D.is_colliding())
True
True
Changing to different tile
False
True
True
True
akien-mga
changed the title
Tilemap collision is not updated when changing tile
Tilemap collision is not updated right away when changing tile (update done in the next collision resolution step)
Oct 26, 2021
I think that's an expected limitation from the way collision checks are done. Recalculating collisions right away after each tilemap change could be very costly when doing bulk changes.
There could maybe be a method to force the PhysicsServer to reprocess shapes and collision for situations where it's wanted though.
Sorry for bumping an old issue, but since I'm moving on past this project and closing the issue for myself, I present my use case and thoughts for future reference for others (why I need to query collision status of tilemap in the same frame it was changed).
Simplified use case
Player states are {Idle, Falling}
Tiles are {Ground, CrackedGround}, both have collision
Tiles can change from Ground => CrackedGround => destroyed
Player is standing on Ground / CrackedGround
Events can change tiles, which signals player to check for possible transition from Idle to Falling
Changing tile from Ground to CrackedGround causes Raycast to report no collision on that frame, causing Player to incorrectly transition to Falling
Workarounds
I can directly check against tile id instead of it's collision. But in a more complex example where only some tiles have collision and others don't, Player would be polluted with needing to know the collision state of all tiles
I can delay the transition by one frame, after the collision resolution has been updated, but this has noticeable effect on responsiveness. If Ground is destroyed at Frame 10, Player should transition from Idle to Falling at end of Frame 10, and be Falling at start of Frame 11
I could re-engineer my state machine transitions to the beginning of frame i.e. check for Idle => Falling transition at start of Frame 11. But... I don't think it really makes sense to perform FSM transitions at start of frame, I'd have to carry over too much state information from previous frame to the next frame
Godot version:
3.3
OS/device including version:
Arch Linux
Issue description:
I need to change a tile then query it's collision status immediately.
This works:
This doesnt:
Minimal reproduction project:
test2.zip
The text was updated successfully, but these errors were encountered: