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
2.18k stars 72 forks source link

Switching Camera Passes through Walls #200

Closed lunarcloud closed 8 months ago

lunarcloud commented 8 months ago

Issue description

I've given the camera a path, I've switched priorities, and it goes through walls.

I was expecting either the camera to avoid walls or it to try to follow the path as it transitions.

Steps to reproduce

Example for an on-rails shooter:


var current_section := 0
var section_targets := [1, 1, 3]

@onready
var camera_path : Path3D = $Shots/Path3D

@onready
var section_cams : Array[PhantomCamera3D] = [$Shots/Section1, $Shots/Section2, $Shots/Section3]

func _on_target_shot():
    section_targets[current_section] -= 1
    if section_targets[current_section] <= 0:
        section_cams[current_section].set_priority(0)
        current_section += 1
        if current_section >= section_cams.size():
            level_complete.emit()
        else:
            section_cams[current_section].set_follow_path(camera_path)
            section_cams[current_section].set_priority(1)

(Optional) Minimal reproduction project

No response

ramokz commented 8 months ago

There's nothing that prevents the camera from going through geometry or colliders, unless you add a CollisionShape to it. Though, doing that could easily lead to it getting caught on a, e.g., a wall, during a tween — so wouldn't recommend it.

What are you looking to achieve?

lunarcloud commented 8 months ago

I just had the camera in a corridor and switching around the corner would clip. I ended up fixing it by adding MORE phantom cameras.

https://github.com/lunarcloud/ggj-2024-rail-shooter

Mostly, I just want a way to suggest a Path or waypoint for the camera to follow on it's way to the next camera.

ramokz commented 8 months ago

It wouldn't really be possible with just two PCams since the tween just interpolates the camera between two PCam positions, or 2 keyframes to use an animation / timeline terminology.

If it were to be dynamically conscious of where walls are, then that sounds more like the kind of behaviour you would find in a navmesh system, which is kind of beyond the scope for this project.

For simple things like corners, you could either use the built-in Tween class and create a dynamic timeline, or, to your point, create more “keyframes” to form a triangular direction by transitioning between multiple PCams in succession.

ramokz commented 8 months ago

Don't think there's anything specific that can be done for this, as this reads as a fairly bespoke request that doesn't have a generic solution.

Feel free to reopen this if you have any suggestions for how to go about it.