Here is a small test project I made to show off my physics based camera. The 3rd person camera never goes inside objects but sadly there is an invisible ball following the camera around which could cause trouble.
www.yoggy.bluegillweb.com/Files/Test.zip
(project file)
I read that and thought, “What prevents it from getting stuck behind objects?” Then I played it an found the answer was “nothing.” Perhaps some collision detection to figure out when its stuck. Either render the obscruction transparent, or remove the sphere from the camera, or both. I’m not sure what the best solution is…
Oh. I know. Maybe cast some rays to the left and right of the sphere so it can a attempt to guess what the best way around the object. If that fails, then eventually just translate/teleport the camera.
:?:
My programming syntax is rusty so I’ll write english.
IF sphere is touching something AND a ray to the character is blocked
disable function that pulls camera rig
//so we dont get pulled back.
//its stuck anyway so turning it off will have no visible effect, right?
REPEAT (arbitary int) times or until the camera rig can shoot a ray at the player unubstructed
cast a ray 45º left of camera vector
cast a ray 45º right of camera vector
IF left ray is longer distance than right ray
move camera rig left
ELSE
move camera rig right
END
END
IF the camera rig is still stuck
just frickin translate it so its next to the player
END
re-enable the function that pulls the camera rig
END
It’s not very efficient. The incriment of movement should be diminishing over each repeat, so that it does not overcompensate and get stuck on something else. Also, it should be calculated instantly from a point rather than moving the camera. Fell free to call me an idiot if that is all just nonsense.