Input handling on mouselook

remotes/1705382094874458415/tmp_refs/heads/godot4-port
Jan 2020-06-14 02:17:43 +02:00
parent 0967492b81
commit 5b21aedbad
3 changed files with 7 additions and 3 deletions

View File

@ -8,6 +8,8 @@ export var MAX_PLAYERS = 10
# Called when the node enters the scene tree for the first time.
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
if is_server:
initialize_server()
else:

View File

@ -36,7 +36,7 @@ remote func jump():
remote func mouselook(rel):
self.rotate_y(- rel.x * MOUSE_SENSITIVITY)
camera.rotate_x(-rel.y * MOUSE_SENSITIVITY)
camera.rotation.x = clamp(camera.rotation.x-rel.y * MOUSE_SENSITIVITY, -PI/2, PI/2)
func motion(delta):
self.move_and_slide(velocity.rotated(Vector3.UP, self.rotation.y) * delta, Vector3.UP)
@ -54,7 +54,9 @@ func _input(event):
# Moouselook
if event is InputEventMouseMotion:
var rel = event["relative"]
var rel = event.relative
rpc("mouselook", rel)
mouselook(rel)
# Jump

View File

@ -10,7 +10,7 @@
script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.70316, -0.0651628 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.33988, -0.0651628 )
[node name="CollisionShape" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 )