Input handling on mouselook
parent
0967492b81
commit
5b21aedbad
2
Game.gd
2
Game.gd
|
@ -8,6 +8,8 @@ export var MAX_PLAYERS = 10
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready():
|
func _ready():
|
||||||
|
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
|
||||||
|
|
||||||
if is_server:
|
if is_server:
|
||||||
initialize_server()
|
initialize_server()
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -36,7 +36,7 @@ remote func jump():
|
||||||
|
|
||||||
remote func mouselook(rel):
|
remote func mouselook(rel):
|
||||||
self.rotate_y(- rel.x * MOUSE_SENSITIVITY)
|
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):
|
func motion(delta):
|
||||||
self.move_and_slide(velocity.rotated(Vector3.UP, self.rotation.y) * delta, Vector3.UP)
|
self.move_and_slide(velocity.rotated(Vector3.UP, self.rotation.y) * delta, Vector3.UP)
|
||||||
|
@ -54,7 +54,9 @@ func _input(event):
|
||||||
|
|
||||||
# Moouselook
|
# Moouselook
|
||||||
if event is InputEventMouseMotion:
|
if event is InputEventMouseMotion:
|
||||||
var rel = event["relative"]
|
var rel = event.relative
|
||||||
|
|
||||||
|
rpc("mouselook", rel)
|
||||||
mouselook(rel)
|
mouselook(rel)
|
||||||
# Jump
|
# Jump
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Camera" type="Camera" parent="."]
|
[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="."]
|
[node name="CollisionShape" type="CollisionShape" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 )
|
transform = Transform( 1, 0, 0, 0, -1.62921e-07, 1, 0, -1, -1.62921e-07, 0, 0, 0 )
|
||||||
|
|
Reference in New Issue