Thread safe dictionary

Much better. Yeah, you don’t need coroutines for this at all. Simply either create the graph when requested or return the cached one if it was already created before.

The key may still cause bugs due to float imprecision. Better to use Vector2i instead of Vector2:

const granularity := 100.0
var key := Vector2i(roundi(speed * granularity), roundi(jump_speed * granularity))

Official docs are quite good.

2 Likes