Use _unhandled_input to control character so it won't interfere with UI coming on top

master
Marc Gilleron 2020-07-23 19:34:30 +01:00
parent dcc32eb030
commit 9359f84345
3 changed files with 4 additions and 3 deletions

View File

@ -80,7 +80,7 @@ func _physics_process(delta):
_action_remove = false _action_remove = false
func _input(event): func _unhandled_input(event):
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.pressed: if event.pressed:
match event.button_index: match event.button_index:

View File

@ -55,6 +55,7 @@ material/0 = null
[node name="CenterContainer" type="CenterContainer" parent="."] [node name="CenterContainer" type="CenterContainer" parent="."]
anchor_right = 1.0 anchor_right = 1.0
anchor_bottom = 1.0 anchor_bottom = 1.0
mouse_filter = 2
__meta__ = { __meta__ = {
"_edit_use_anchors_": false "_edit_use_anchors_": false
} }
@ -64,4 +65,5 @@ margin_left = 504.0
margin_top = 292.0 margin_top = 292.0
margin_right = 520.0 margin_right = 520.0
margin_bottom = 308.0 margin_bottom = 308.0
mouse_filter = 2
texture = ExtResource( 4 ) texture = ExtResource( 4 )

View File

@ -1,4 +1,3 @@
extends Spatial extends Spatial
export var sensitivity = 0.4 export var sensitivity = 0.4
@ -18,7 +17,7 @@ func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED) Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _input(event): func _unhandled_input(event):
if event is InputEventMouseButton: if event is InputEventMouseButton:
if event.pressed and Input.get_mouse_mode() != Input.MOUSE_MODE_CAPTURED: if event.pressed and Input.get_mouse_mode() != Input.MOUSE_MODE_CAPTURED:
if capture_mouse: if capture_mouse: