How can I use Phantom Camera in a first-person game with cutscenes? #361
-
I'm working on a first-person perspective game. My player scene's root is a CharacterBody3D. It has a child Camera3D which is controlled by the player script to look around with the mouse. My first "level" of the game has a few cutscenes in which I've animated several other Camera3Ds. I want to use Phantom Camera to make life a little easier, and I've been playing around with it and learning how to manage multiple PCams. The problem is that, as far as I can tell, Phantom Camera needs there to be exactly one Camera3D with a child of type PhantomCameraHost at the first level of the scene tree. So how can I handle the player scene having it's own Phantom Camera and switch between it and the cutscene cameras? I've tried giving the player an exported var called p_cam, then adding a PCam to my level and assigning it in the p_cam slot in the editor. And I have an animation that plays when the level is started to control the priorities of the various cameras. But when I start my level I just get a grey screen. It feels like I'm using Phantom Camera incorrectly, like it's only meant for controlling a 3rd person camera and not like what I'm trying to do. Is there a way to make it work in a first-person game with cutscenes? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
I think I may have found a solution. I removed any Camera3Ds and PCams from my player scene and added a Node3D called PCamPlaceholder where the Camera3D was originally positioned, with the same orientation. I added this line to the player script to get a reference to it:
In my level scene I added a PhantomCamera3D called PlayerPhantomCamera3D. For this player PCam I set follow mode to glued and look at mode to mimic, and I set the tween duration to 0. Now in my level script I set everything up in the _ready function:
And with that, everything seems to be working. When I want to animate cameras in some cutscene I use this method:
And when I want to end the cutscene I use this method:
|
Beta Was this translation helpful? Give feedback.
I think I may have found a solution. I removed any Camera3Ds and PCams from my player scene and added a Node3D called PCamPlaceholder where the Camera3D was originally positioned, with the same orientation. I added this line to the player script to get a reference to it:
In my level scene I added a PhantomCamera3D called PlayerPhantomCamera3D. For this player PCam I set follow mode to glued and look at mode to mimic, and I set the tween duration to 0. Now in my level script I set everything up in the _ready function: