3rd Person Camera for Controller

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By CreekWorks

I am trying to add controller support to a camera made by [Code with Tom][1]. It uses mouse input to move however I would like to be able to use a joystick. I tried doing so myself but with my limited knowledge of Godot especially 3D I can’t get it to work. Thanks in advance.

Here is the code

extends KinematicBody

export(float, 0.1, 1) var mouse_sensitivity : float = 0.3
export(float, -90, 0) var min_pitch : float = -90
export(float, 0, 90) var max_pitch : float = 90

var velocity : Vector3
var y_velocity : float

onready var camera_pivot = $CameraPivot
onready var camera = $CameraPivot/CameraBoom/Camera

func _ready():
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

func _process(delta):
	if Input.is_action_just_pressed("ui_cancel"):
		Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)

func _input(event):
	if event is InputEventMouseMotion:
		rotation_degrees.y -= event.relative.x * mouse_sensitivity
		camera_pivot.rotation_degrees.x -= event.relative.y * mouse_sensitivity
		camera_pivot.rotation_degrees.x = clamp(camera_pivot.rotation_degrees.x, min_pitch, max_pitch)

  [1]: https://www.youtube.com/channel/UCdU9e4eNsJif0rBrBiYRb5g

Have you looked at the Third Person demo, especially the “player.gd” file?

Ertain | 2020-08-05 23:35

I have not, thank you I will go ahead and look at it I didn’t know it existed

CreekWorks | 2020-08-05 23:37