ramokz / phantom-camera

šŸ‘»šŸŽ„ Control the movement and dynamically tween 2D & 3D cameras. Built for Godot 4. Inspired by Cinemachine.
https://phantom-camera.dev/
MIT License
1.93k stars 62 forks source link

Set spring arm to "top level" when in Third Person #233

Closed jrburga closed 2 months ago

jrburga commented 3 months ago

Set _follow_spring_arm_node.top_level = true when creating it and adding it to the parent node (which is the parent node of the PhantomCamera3D at this point). This allows you to add the PhantomCamera3D to the moving character instance and still have it follow the character without the the spring arm inheriting the character's position. The PhantomCamera3D will be reparanted to the spring arm later on, so the PhantomCamera3D shouldn't be top_level.

This is just a slight qol improvement I think that made sense for my use case, but also might be helpful for others trying to do something similar.

jrburga commented 3 months ago

For reference, here's a basic setup experimenting with placing the Phantom Cameras inside the CharacterBody, allowing more direct access to things like 3rd person camera rotation from within the player controller code, without having to "@export" or otherwise "find" the Phantom Cameras elsewhere.

image
ramokz commented 3 months ago

Think this is a good idea!

Testing this a bit further, think this would be appropriate for all follow modes. That said, the treatment for non-Third Person follow is slightly different, but trivial to add either way. Just need to check the follow mode isn't THIRD_PERSON on _enter_tree() function and set it to top_level there as well.

I am currently working towards v0.7, which effectively changes the entire property system, so would prefer to keep this PR on stand-by until it's merged into the main branch and then add this in a follow-up release.

ramokz commented 2 months ago

With 0.7 now being out, this should just be a case of applying the change to the updated file that is now called phantom_camera_3d (notice the lowercased ā€œdā€ at the end) somewhere below line 536.

ramokz commented 2 months ago

Resolved as part #282