I am developing a Vision OS app. In the fully immersive view, I want to simulate a person flying in an airplane. How can I change the camera perspective to the cockpit view (first-person view) or back to the airplane (third-person view)? Currently, the camera is in a static view; only the airplane moves while the camera remains in the same place. The airplane object is a 3D USDZ object. Any help would be appreciated. Thanks in advance.
You can do it by having two different models: one is the airplane, one is inside the airplane. Then create a skybox of the sky. Then add a scene of airplane flying outside, and another scene of inside the airplane, then control which scene to show by a toggle. For example:
enum MainViewState {
case thridPersonView, firstPersonView
}
var body: some View {
ZStack {
//create three realityViews, the sky is aways showing, the other two controlled by state of viewState
createSkyView().frame(depth: 0)
createAirplaneView().opacity(viewState == .thridPersonView ? 1 : 0).frame(depth: 0)
createFirstPersonView().opacity(viewState == .firstPersonView ? 1 : 0).frame(depth: 0)
}