alessandrofama / wwise-godot-integration

Wwise Integration for the Godot Engine
Other
288 stars 14 forks source link

Fix enter/exit room bug #107

Open ak-pvasudev opened 2 weeks ago

ak-pvasudev commented 2 weeks ago

Hi Alessandro,

This is the fix for the enter/exit room bug. Prior to this fix, sound would drop out as we changed rooms because after the player entered the new room, it would call _on_area_exited() on the old room, which would set the player's room ID to INVALID_ROOM_ID.

To fix this problems we make two substantive code changes:

  1. When the player enters a new room, have the method _on_area_entered() set the player's room ID to the room they are in. If a player goes outside, then _on_area_entered() is not called because outdoors is not a room.
  2. When the player exits a room compare the room the player is in with that they're exiting. If they are the same (because the player has not entered another room) it means the player is going outside and we set the room ID to INVALID_ROOM_ID.

I've left a detailed comment in _on_area_exited() explaining this.

All tests pass locally; ideally we would have an automated test in a game environment simulating the transition between two rooms, but I'm not sure if that is something we have right now.

Thanks!