make multiplayer input consider devices
This commit is contained in:
@@ -69,6 +69,25 @@ func get_action_prompt(action: StringName) -> String:
|
||||
return _get_event_prompt(events[0]) if events.size() != 0 else "???"
|
||||
|
||||
|
||||
func get_vector_from_raw_strengths(
|
||||
negative_x: float,
|
||||
positive_x: float,
|
||||
negative_y: float,
|
||||
positive_y: float,
|
||||
deadzone := 0.5
|
||||
) -> Vector2:
|
||||
var vector := Vector2(positive_x - negative_x, positive_y - negative_y)
|
||||
|
||||
var length := vector.length()
|
||||
|
||||
if length <= deadzone:
|
||||
return Vector2.ZERO
|
||||
if length > 1.0:
|
||||
return vector.normalized()
|
||||
|
||||
return vector * inverse_lerp(deadzone, 1.0, length) / length
|
||||
|
||||
|
||||
func get_event_mode(event: InputEvent) -> Mode:
|
||||
if event is InputEventJoypadButton or event is InputEventJoypadMotion:
|
||||
return Mode.CONTROLLER
|
||||
|
||||
Reference in New Issue
Block a user