UPBGE 0.3: 3rd Person Camera System

Camera will go around objects with property "ground"

Camera Rotation with mouse only when ctrl is pressed.

Keyboard and Gamepad always work.
    Arrow keys: Rotate
    pgdown/pgup / Mousewheel: zoom
    Home/ MiddleMouseButton: reset Zoom
    
    Key F: toggle follow mode

Joystick selection menu:
     Show/Hide: Key J
     Toggle through: Left Mouse click 

In the lerp.py code there are 2 follow modes available to use: 
1. Align camera to players velocity
2. Align camera behind player  


The player movement is controlled by move.py

UPBGE_0.3_3rdPerson_Camera.blend (875.7 KB)

1 Like

I’m reviving a bit of an older post but I wanted to say that I’ve been enjoying using your 3rd Person Camera System. I have a hopefully simple request. Can you help me understand how to switch the controller functions so that the left stick controls the motion and the right controls the camera? Thanks again for sharing this useful camera system.

Oh yes, the code is not so elegant. You have to change the axisValues in 2 files:
For movement in move.py and for Camera in lerp.py.

In move.py change ALL(!) axisValues number 3 and 2 to 1 and 0:
3->1
2->0
from this:

if Joystick!=None:
    if Joystick.numAxis>3:
        if abs(Joystick.axisValues[3])>Joystick_threshold: x += Joystick.axisValues[3]**3*Joy_sensitivity
        if abs(Joystick.axisValues[2])>Joystick_threshold: y += Joystick.axisValues[2]**3*Joy_sensitivity

to this:

if Joystick!=None:
    if Joystick.numAxis>3:
        if abs(Joystick.axisValues[1])>Joystick_threshold: x += Joystick.axisValues[1]**3*Joy_sensitivity
        if abs(Joystick.axisValues[0])>Joystick_threshold: y += Joystick.axisValues[0]**3*Joy_sensitivity

In lerp.py change ALL(!) axisValues number 0 and 1 to 2 and 3:
0->2
1->3
from this:

    if Joystick!=None:
        if abs(Joystick.axisValues[0])>Joystick_threshold: x += Joystick.axisValues[0]**3*Joy_sensitivity
        if abs(Joystick.axisValues[1])>Joystick_threshold: y += Joystick.axisValues[1]**3*Joy_sensitivity

to this:

    if Joystick!=None:
        if abs(Joystick.axisValues[2])>Joystick_threshold: x += Joystick.axisValues[2]**3*Joy_sensitivity
        if abs(Joystick.axisValues[3])>Joystick_threshold: y += Joystick.axisValues[3]**3*Joy_sensitivity

Thanks, I really appreciate the help! Your changes worked perfectly. I’m not really qualified to judge the elegance of the code but I like its in-game feel.

I hope to be able to learn a bit more with regards to using python with upbge. Right now I have walk, run and idle animations working with logic nodes but need to learn more about how to integrate these better with the player movement.