Phazorknight / Cogito

Immersive Sim Template Project for GODOT 4
MIT License
717 stars 81 forks source link

Crash when shooting laser rifle after scene transition #140

Closed samaritan-sw closed 3 months ago

samaritan-sw commented 3 months ago

Cogito and Godot Engine Version: Godot 4.2.1 and Cogito latest

Description: Shooting the laser rifle picked up in demo scene 5 after transitioning to scene 4 results in a crash. This does not happen with the foam pistol from scene 5, and the scene doesn't crash if, after loading scene 4, you put away the rifle, then equip it again before shooting.

Reproduction steps:

Expected behavior: The rifle shoots.

Screenshots: image

Phazorknight commented 3 months ago

Thanks for the flag! Could you check if https://github.com/Phazorknight/Cogito/commit/84bc8a7a3597e7c92ccba21b692b84fc0d054d1e fixes this for you?

The reason was that when the laser rifle gets equipped, it grabs a scene reference. But when the scene isn't fully loaded yet, this reference is null, resulting in the error you saw. I've changed this to be a deferred call, which seems to fix this.

samaritan-sw commented 3 months ago

Nice one, that fixed it! 😄