Make the camera motion less jerky with the gamepad

Added deadzone support
Increased smoothing on the camera
This commit is contained in:
Nathan Lovato 2019-07-26 15:50:21 +02:00
parent 312b2eb0c4
commit 08cf19c04c
3 changed files with 8 additions and 10 deletions

View file

@ -193,22 +193,22 @@ sprint={
]
}
aim_left={
"deadzone": 0.5,
"deadzone": 0.6,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null)
]
}
aim_right={
"deadzone": 0.5,
"deadzone": 0.6,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null)
]
}
aim_up={
"deadzone": 0.5,
"deadzone": 0.6,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null)
]
}
aim_down={
"deadzone": 0.5,
"deadzone": 0.6,
"events": [ Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null)
]
}

View file

@ -6,7 +6,7 @@ Rig to move a child camera based on the player's input, to give them more forwar
onready var camera: Camera2D = $ShakingCamera
export var offset: = Vector2(200.0, 160.0)
export var offset: = Vector2(300.0, 300.0)
export var mouse_range: = Vector2(100.0, 500.0)
var is_active: = true
@ -28,7 +28,5 @@ func update_position(velocity: Vector2 = Vector2.ZERO) -> void:
camera.position = distance_ratio * mouse_position.normalized() * offset
Settings.GAMEPAD:
var joystick_direction: Vector2 = ControlUtils.get_aim_joystick_strength()
if Input.is_action_pressed("move_right") or Input.is_action_pressed("move_left"):
camera.position.x = sign(velocity.x) * offset.x
camera.position.y = joystick_direction.y * offset.y
var joystick_strength: = ControlUtils.get_aim_joystick_strength()
camera.position = joystick_strength * offset

View file

@ -11,7 +11,7 @@ script = ExtResource( 1 )
current = true
process_mode = 0
smoothing_enabled = true
smoothing_speed = 7.0
smoothing_speed = 3.0
drag_margin_left = 0.0
drag_margin_top = 0.0
drag_margin_right = 0.0