Chapter 9 ThirdPersonCamera Thread error

Hello,

I am trying to implement the ThirdPersonCamera in Chapter 9. When I run the program, it automatically crashes and I get the following error: Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT) on the line rotation.y = focus.rotation.y in the override for viewMatrix.

Any help would be appreciated. Thanks!

So, it seems that this crash is related to the same crash with ArcballCamera. Here’s my work around for it

override var viewMatrix: float4x4 {
    position = focus.position - focusDistance * focus.forwardVector
    position.y = focusHeight
    let y = focus.rotation.y
    let x = rotation.x
    rotation = [x, y, 0]
    return super.viewMatrix
}

Yes, unfortunately this appeared with a recent release of Xcode. I’m glad you found the fix.

@albertk Thank you for sharing your solution - much appreciated!