![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ManiCus |
Move mouse with controller :v
![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | ManiCus |
Move mouse with controller :v
![]() |
Reply From: | muratbozkurt35 |
https://forum.godotengine.org/5878/set-mouse-position
you can use this i suppose.
use controller input to add or substract x and y values to mouse position instead adding motion to character.
![]() |
Reply From: | estebanmolca |
I don’t have a joystick to test it but this should work (works fine with arrows):
var mouse_sens= 300.0
func _physics_process(delta):
var direction: Vector2
direction.x = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left")
direction.y = Input.get_action_strength("ui_down") - Input.get_action_strength("ui_up")
if abs(direction.x) == 1 and abs(direction.y) == 1:
direction = direction.normalized()
var movement = mouse_sens * direction * delta
if (movement):
get_viewport().warp_mouse(get_global_mouse_position()+movement)
![]() |
Reply From: | lukifah |
use
Input.warp_mouse_position(get_viewport().get_mouse_position()+movement)
instead
movement is the Vector2 after getting joystick input strength
on ready you can
func _ready() → void:
Input.set_mouse_mode(Input.MOUSE_MODE_CONFINED)