I have the latest PDF version of the book. There is a script given for switching guns, that does not allow for switching to the Assault Rifle. I edited my code to allow for it, but others may encounter this issue. Below is what is in the text.
Thanks for pointing this out. I’ve made a fix locally so it will go out in the next update.
Thankfully, if you continue a little further in the chapter, you will find the correct code is there. It looks like the first time this code block is shown it was missing one of the conditions. It should be:
void Update()
{
if (Input.GetKeyDown("1"))
{
loadWeapon(pistol);
activeWeaponType = Constants.Pistol;
} else if (Input.GetKeyDown("2"))
{
loadWeapon(assaultRifle);
activeWeaponType = Constants.AssaultRifle;
} else if (Input.GetKeyDown("3"))
{
loadWeapon(shotgun);
activeWeaponType = Constants.Shotgun;
}
}
Sorry for the confusion this might have caused, and thanks for bringing this up here.
I was going to comment just that!
It’s missing one “else if” block, it should be one for pistol, one for Assault rifle and finally one for the shotgun!