Figured I’d upload this third person camera I’ve been making since I put quite a bit of work into it.
The logic brick setup is extremely simple since it mostly consists of Python code.
In addition to mouse smoothing and zooming, it uses ray sensors to avoid objects that have a “camera blocking” property. For example, if an object passes between the player character and the camera, the camera will jump in front of the object. If there is an obstruction behind the camera, it will move closer to the player to avoid clipping through walls and the like.
I put a couple planes in the scene with the camera blocking property to demonstrate this feature.
Hope you guys find it useful!
EDIT:
Did a bit more work on the camera. The updated file is in a post below.
I will use it and you will be in the Credits for the game, and I’m asking cause I don’t want to mess this up: Can you add a Zoom function to it? (I can but its cheap)
There’s already a vertical limit. If you want to change it, just adjust the value of MIN_ANGLE at the top of the script. If you want to implement at horizontal limit, you can do a few small tweaks of your own. Check lines 122-125 for how the vertical limit is implemented. Just do something similar in lines 116-121.
As a side note, looking back on this script now I notice it’s somewhat sloppy. There are unused variables laying around, and it could use a bit of optimization. I may come back to it sometime and rework it, but for now at least it’s functional.
Thanks Mobious - love how well this script works! I didn’t find a variable called MIN_ANGLE, only a MIN_DIST; but I was able to limit the vertical angle with the bounds you set at lines 109 - 112.
Oh, you’re using the first version. I was looking at the second version of the script. It has a couple more features that are handy if you want to download it (it’s in post #6).
One question because i think i’m gonna use your script in my project, how would you proceed to add character’s (or any kind of object) movements? If you could just explain the main things you would do, i’d appreciate a lot.
I’ve tried, in your demo file, parenting the camera to Suzanne, adding a keybrd sensors to her as she can moves forward; but i was wondering how about make her turn left or right according to camera rotation…
May be, it could be interesting to make your current script be the “looking around mode” part of a script that would manage movement in a “default mode”.
Im trying to make it so when you hold rmb, it zooms in, and when you release rmb, it zooms out, do you know what i should do for that? your script is awesome btw