478798 (1) [Avatar] Offline

I enjoyed the beta chapter of this book but it did bother me that the sprite doesn't 'Idle' in the last direction travelled. So just a small suggestion really, to alter the code to ensure the sprite, when finished moving, is 'Idle' in the same direction.

if (Mathf.Abs(deltaX) != 0)
{ // change direction
  transform.localScale = new Vector3(Mathf.Sign(deltaX) / platformScale.x, 1 / platformScale.y, 1);

Just an ickle bit of polish, perhaps left as an exercise for the reader.

Thanks again,
jhocking (202) [Avatar] Offline
Thanks, cool suggestion! I'll check it out.

(by the way, it's unnecessary to get the absolute value for that check; positive or negative, either way is not zero)
internationalfish (6) [Avatar] Offline
This has been bothering me. Working with floats, shouldn't you compare to epsilon or use Mathf.Approximately with 0f instead of doing an equality operation on zero?
jhocking (202) [Avatar] Offline
Mathf.Approximately() does indeed exist explicitly for this purpose: comparing floating point values. I suppose that method would've been a good idea, but in this case Input will in fact return 0 when nothing is pressed, not just almost 0.