0 votes

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
in Engine by (125 points)

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

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

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.