My camera went through any geometry so I thought I’d come up with a solution, been getting used to python recently and I thought I could do this Comes to show my hands aren’t as mighty as I thought. Here is the script:
cameraE = scene.objects["cameraEmpty"] camera = scene.objects["Camera"] playerE = scene.objects["camera_empty"] cameraOrigPos = scene.objects["cameraOriginal"] #empty at the original position of camera obj, hitPoint, normal = playerE.rayCast(cameraE, playerE, 0, "", 0, 0, 0) #ray from player empty to camera empty. init = 0 if obj != None: camera.position = hitPoint init = 1 if obj == None: if init == 1: camera.position = cameraOrigPos.position init = 0
Console gives no errors but I feel something in there is fundamentally wrong.
When the ray collides with something the camera goes mental and snaps to a point close to the player rather then one that the collision was with.
I originally thought that the ray may be colliding with my character controller capsules mesh, but that is not the case,