UQdeco2800 / 2022-studio-2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Game Crashing upon attacking without weapon

IshaanM8 opened this issue · comments

Description

If the user presses space bar (which is the input for attack) and a weapon is not currently equipped, the game tends to crash.

How To Reproduce

Steps to reproduce the behaviour:

  1. Start game with gradlew run
  2. Press play and hit enter to get into the game
  3. Press Space Bar to attack which crashes the game
  4. Game then exists due to said crash

Expected Behaviour

Upon pressing space bar, the player should hit the air / do no damage if a weapon is not equipped, else if they have a weapon, it should act as intended and damage entities / enemies as designed to do so.

Temporary Fix

Pickup the closest weapon possible and equip it, which can then be used to attack entities in the area without crashing.

@IshaanM8 Thanks for pointing this one out to me! I've pushed out a fix to the main branch and you should now be able to verify when pressing space, that the attack sound plays as expected.

The issue was caused by failing to check for null values first in the playAttackSounds() function.