- Edited
So at the moment I have a kinematic body and a platform to collide against. I have a scene for the KinematicBody itself to keep it seperate from the game, which has two extra gimbal spatial nodes, main gimbal for 3rd person left and right rotation and the inner gimbal for the up and down rotation. (i forget the cooardinates, im assuming its not the same as Blender) The camera is attached to the first gimbal node and its position is offset to the player. Basically a 2 axis gimbal system to replicate a 3rd person camera!! I learnt this by watching https://youtube.com/watch?v=ypCP2cKyh68 which helped me a lot.
extends Spatial
func _ready():
set_process(true)
func _process(delta):
var left_analog_axis = Vector2(Input.get_joy_axis(0,JOY_AXIS_2), Input.get_joy_axis(0, JOY_AXIS_3)) * 1
rotate_y(-left_analog_axis.x * delta)
get_node("innergimbal").rotate_x(-left_analog_axis.y * delta)
if left_analog_axis.length() > 0.25:
rotate_y(0 * delta)
get_node("innergimbal").rotate_x(0 * delta)
this code is utilizing an analog stick from a ps4 controller. It works well enough. I can rotate around the player along with the values from the axis meaning I can allow for pressure sensitivity. I've also applied similar code to the kinematic body itself which looks like this.
extends KinematicBody
func _ready():
set_physics_process(true)
func _physics_process(delta):
var left_analog_axis_move = Vector2(Input.get_joy_axis(0,JOY_AXIS_0), Input.get_joy_axis(0, JOY_AXIS_1))
if left_analog_axis_move.length() > 0.25:
move_and_slide(Vector3(left_analog_axis_move.x * 15, 0, left_analog_axis_move.y * 15))
I can move the player forward, backward, left and right along with the pressure sensitivity. The camera rotates around the player, but does not change the direction the player is facing. Is there any way around this? I assume that this is a common problem with 3rd person cameras. This could be due to a lack of understanding the concepts behind 3rd person camera techniques. Any suggestions or help would be much appreciated. I'm going to link to my current godot proj so feel free to take a look.
https://github.com/winnieTheWind/3rdPersonCameraWithAnalogStick
Thanks.