i need a non-language specific algorithm for a 3rd person camera. what im having trouble with is how to keep the camera behind the object and keep the camera’s rotation the same as the objects rotation. any ideas?
Example:
UpdateCamera(camera, target){
offset = vector(0,height,distance);
cameraPos = targetPos+offset;
camAngle = ?????;
}
i know it won’t be that simple but im sure you’ll get the gist of it.
At its absolute simplest, suppose you have a simple NUV camera class like this:
Now, each frame:
1) Get the position
ppand directionpdirof the player.2) Recreate your camera with position =
pp - offset * pdir, look =pdirand up = something sensible (e.g.(0,0,1)).