Navigation in third person view with obstacles and occluders - looking for ideas

Howdee, I am looking for ideas, tips, examples to make the perfect controller which will avoid my camera and avatar go through obstacles and will smoothly lerp my camera in front of occluders between the camera and avatar. Especially the latter seems complicated:

  • how to lerp/animate the camera nicely around an occluder? Is wayfinding required? can I use physics?
  • how to detect if occluder animation is needed? walking around a thin lamppost should not put me in front of the occluder, for example.

As I am sure this is not the first time this problem has been encountered, I hope the community can help me getting started.
Thanks !

I think it’s hard to come up with a general-purpose 3rd-person camera controller that won’t look bad in some situations.

You’ll have to take the controls into account; if you want the UP key to always walk the character forward, you’ll need to keep the camera generally “behind” the character to avoid confusing the user.

If the camera is mostly top-down and the user clicks the ground with the mouse to set the target point, you might be able to use pathfinding to smoothly move both the character and camera to good new locations.

I think the best-looking systems keep the camera on a predefined path determined by a designer or have predefined camera locations and the camera slides along the path or moves from view to view as the character moves.

Consider what you want to happen if the character faces away from a wall and then backs up; do you want the camera to stop at the wall and let the character back up closer and closer? Should the character go translucent so you can see through, or should the camera climb up the wall and look down?

Consider the same case when near a corner and the character wants to spin around; you can detect camera collisions and occlusions and slide the camera closer to the character along one wall and then slide back out on the other, but it never looks great.

Consider what you want to happen if the character faces a pole and then rotates around quickly, swinging the camera around behind; should you ignore pole collisions and occlusion and just go translucent so you can see through it without colliding?

Walls are often treated differently than smaller objects, with walls remaining solid and smaller objects going translucent.

Look to game development for ideas on how to handle this.

Simple solutuon. Raycast from person back to camera direction.
If no intersection, then camera distance 2 meters, if have intersetion, then place camera to intersection point minus 20 cantimeters.
image

Thanks for the suggestion. This is indeed what I am doing. My struggle lies more in these two cases:

  • For the left case I do not want to ‘slide’ to the left but find a smarter route
  • For the right case I would like to get some idea of the shape/size of the obstacle (think of avatar behind a fence with vertical bars); shooting rays from each corner of my viewport to the focal point/avatar (4 rays) could be a way: if all 4 rays are obstructed, consider it a valid obstacle. But my feeling says this will not cover all cases so why bother with the overhead.

Need pathfinding how its done in game for bots.
https://mugen87.github.io/yuka/examples/navigation/navmesh/
https://mugen87.github.io/yuka/examples/navigation/navmeshPerformance/
https://mugen87.github.io/yuka/examples/navigation/navmeshPerformance/
https://mugen87.github.io/yuka/examples/navigation/firstperson/
https://mugen87.github.io/yuka/examples/steering/obstacleAvoidance/

https://www.jdxdev.com/blog/2021/12/07/rts-pathfinding-3-variable-agent-size-smoke-tests-navmesh-fixes/

1 Like

Firing 4 rays from the view plane corners to the player helps the left case; there will be a moment when the left rays first become obscured and the right rays are not, so you can rotate the camera to the right or zoom in close until the left rays are no longer obscured. The same approach might help the right case, depending on how large the gap is.

The player could also drop bread crumbs to indicate the valid path to give the camera hints, or you could pre-define several positions in an arc behind the player and select one that gives a clear view.