Errata: August 25, 2018

Thank you for purchasing Unity in Action, Second Edition. Please post any errors, other than those listed below, in the book's Author Online Forum. We'll update this list as necessary. Thank you!


Instruction in section 4.5.2 (page 92)
These instructions for applying a texture work in older versions of Unity, but imported materials work slightly differently now. There are several ways to make it work correctly, but the simplest is to first click Extract Materials in the Materials tab of the imported model.

Speed in listing 6.1 (page 132)
Unlike in previous chapters, we're manipulating the player's velocity not position, so delta time is not needed. Replace the first line in Update() with "float deltaX = Input.GetAxis("Horizontal") * speed;". Now the speed value needs to be much lower, so change the variable declaration to the following:
"public float speed = 4.5f;"

Number comparison in listing 6.5 (page 140)
The check "deltaX == 0" should be replaced with "Mathf.Approximately(deltaX, 0)". Thus the entire line of code becomes:
_body.gravityScale = (grounded && Mathf.Approximately(deltaX, 0)) ? 0 : 1;

Number comparison in listing 6.8 (page 143)
Similar to the previous change, the line "if (deltaX != 0)" should be replaced with "if (!Mathf.Approximately(deltaX, 0))". The latter appears in listing 6.2 and 6.8 refers to that same line of code, but 6.8 has the incorrect version.

Dot product in listing 9.3 (page 201)
When using the dot product to check facing, the vectors must be normalized (i.e. scaled to a length of 1 while retaining direction). Replace the dot product line with the following:
"if (Vector3.Dot(transform.forward, direction.normalized) > .5f) {"