help me with third person camera system

blend file:

i was looking for a third person that can rotate camera around player and i found this, but he don’t have a cap to stop the camera.

if you have a better third person that rotate camera around player please give .blend link

how to add a cap in this code?:

import GameLogic as g

import mathutils

from mathutils import Vector

scene = g.getCurrentScene()

co = bge.logic.getCurrentController()

o= co.owner


ray = co.sensors["Ray"]

muro = ray.hitObject

normal_vec = Vector(ray.hitNormal)

Camera = scene.objects["Camera"]

Empty = scene.objects["cameraTarget"]

Plano = scene.objects["Plane_collision"]

if ray.positive:
    Camera.worldPosition = ray.hitPosition
    Camera.localPosition.y -= 1.3

    Camera.worldPosition = Empty.worldPosition

Look into resource section, lots of free scripts there (with cap), or take a look at my sig.
As your example needs to be extended/rewritten, best is to grab one that is working already.

You can also use the camera brick, (no idea if that one has a cap)

Take a look at Mobius’ 3rd Person Camera

i still did not find a third person that can rotate camera around player like this one with cap, any one have? thank you