- Edited
I can't seem to figure out how to get a mutex lock to work correctly.
Here's my code:
var bullet_lock = Mutex.new()
#bullet_lock.lock()
#bullet_lock.unlock()
if (bullet_lock.try_lock()):
print("bullet not locked yet")
print("locking")
bullet_lock.lock()
else:
print("bullet already locked")
bullet_lock.lock()
The output is always "bullet already locked". Even if I uncomment the "bullet_lock.unlock()" line. I feel like I'm just trying to use .lock() or .try_lock() incorrectly. I tried searching, but I only got this post, which doesn't seem to be helping me: https://godotengine.org/qa/6219/need-an-example-on-how-to-use-metux-lock-and-lock-threading?show=6219#q6219 Any help would be appreciated.