MatejSloboda / Dijkstra_map_for_Godot

MIT License
77 stars 13 forks source link

crash in project_example.tscn #100

Closed arnaudgolfouse closed 3 years ago

arnaudgolfouse commented 3 years ago

There's a bug in the project_example too. I had it crash out when I was clicking around with the dragon:

image

I've tried replicating with a few hundred clicks but it seems to have been one of those annoying rare bugs. :-( Figured I'd raise it here so you're aware of it. Feel free to create a new issue if you want.

_Originally posted by @CitrusWire in https://github.com/MatejSloboda/Dijkstra_map_for_Godot/issues/99#issuecomment-758858827_

I thought it would be better to give it its own issue

arnaudgolfouse commented 3 years ago

Ok I think I got what caused this !

In theory archers and pikemen should never find themselves on water; but godot physics is a bit weird, and if you push them with the dragon, they can end up in water, and our code crashes because we do dictionary indexing with [].

Solving could be possible by replacing

point_position_to_id[map_coords]

by

point_position_to_id.get(map_coords, 0)

in get_direction_for_archer and get_direction_for_pikeman.

Now characters are immobilized once they step in water, so maybe this is not optimal 😅