Fix observer yaw and pitch

This commit is contained in:
Paul Von Zimmerman
2017-07-28 14:42:43 -07:00
committed by Rémi Verschelde
parent f61c760e62
commit 893348428e
3 changed files with 104 additions and 75 deletions

View File

@@ -37,9 +37,10 @@ func _physics_process(delta):
move_and_collide(dir * 10 * delta)
var d = delta * 0.1
var yaw = get_transform().rotated(Vector3(0, 1, 0), d * r_pos.x)
set_transform(yaw)
# set yaw
rotate(Vector3(0, 1, 0), d*r_pos.x)
# set pitch
var pitch = $Camera.get_transform().rotated(Vector3(1, 0, 0), d * r_pos.y)
$Camera.set_transform(pitch)
@@ -48,7 +49,7 @@ func _physics_process(delta):
func _input(event):
if (event is InputEventMouseMotion):
r_pos = event.relative
r_pos = -event.relative
if (event.is_action("ui_cancel") and event.is_pressed() and !event.is_echo()):
if (state == STATE_GRAB):

View File

@@ -2,36 +2,45 @@
[ext_resource path="res://observer/observer.gd" type="Script" id=1]
[node name="Observer" type="KinematicBody"]
[node name="Observer" type="KinematicBody" index="0"]
input_ray_pickable = true
input_capture_on_drag = false
collision_layer = 1
collision_mask = 1
axis_lock_linear_x = false
axis_lock_linear_y = false
axis_lock_linear_z = false
axis_lock_angular_x = false
axis_lock_angular_y = false
axis_lock_angular_z = false
collision/safe_margin = 0.001
script = ExtResource( 1 )
[node name="Camera" type="Camera" parent="."]
[node name="Camera" type="Camera" parent="." index="0"]
projection = 0
fov = 60.0
near = 0.1
far = 1000.0
keep_aspect = 1
current = false
cull_mask = 1048575
environment = null
h_offset = 0.0
v_offset = 0.0
doppler/tracking = 0
doppler_tracking = 0
projection = 0
current = false
fov = 60.0
size = 1.0
near = 0.1
far = 1000.0
[node name="OmniLight" type="OmniLight" parent="."]
[node name="OmniLight" type="OmniLight" parent="." index="1"]
layers = 1
light_color = Color( 1, 1, 1, 1 )
light_energy = 1.0
light_indirect_energy = 1.0
light_negative = false
light_specular = 0.5
light_bake_mode = 1
light_cull_mask = -1
shadow_enabled = false
shadow_color = Color( 0, 0, 0, 1 )

View File

@@ -10,13 +10,13 @@ subdivide_width = 0
subdivide_height = 0
subdivide_depth = 0
[node name="Spatial" type="Spatial"]
[node name="Spatial" type="Spatial" index="0"]
[node name="Observer" parent="." instance=ExtResource( 1 )]
[node name="Observer" parent="." index="0" instance=ExtResource( 1 )]
transform = Transform( 0.910685, 0, -0.4131, 0, 1, 0, 0.4131, 0, 0.910685, -4.81287, -0.152566, 9.90641 )
[node name="MeshInstance" type="MeshInstance" parent="."]
[node name="MeshInstance" type="MeshInstance" parent="." index="1"]
layers = 1
material_override = null
@@ -31,20 +31,20 @@ mesh = SubResource( 1 )
skeleton = NodePath("..")
material/0 = null
[node name="Control" type="Control" parent="."]
[node name="Control" type="Control" parent="." index="2"]
anchor_left = 0.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 1.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
script = ExtResource( 2 )
[node name="Button_Fullscreen" type="Button" parent="Control"]
[node name="Button_Fullscreen" type="Button" parent="Control" index="0"]
anchor_left = 0.0
anchor_top = 0.0
@@ -55,8 +55,9 @@ margin_top = 20.0
margin_right = 120.0
margin_bottom = 45.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = true
@@ -65,8 +66,9 @@ shortcut = null
group = null
text = "Fullscreen"
flat = false
align = 1
[node name="Button_FixedSize" type="Button" parent="Control"]
[node name="Button_FixedSize" type="Button" parent="Control" index="1"]
anchor_left = 0.0
anchor_top = 0.0
@@ -77,8 +79,9 @@ margin_top = 60.0
margin_right = 120.0
margin_bottom = 85.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = true
@@ -87,8 +90,9 @@ shortcut = null
group = null
text = "FixedSize"
flat = false
align = 1
[node name="Button_Minimized" type="Button" parent="Control"]
[node name="Button_Minimized" type="Button" parent="Control" index="2"]
anchor_left = 0.0
anchor_top = 0.0
@@ -99,8 +103,9 @@ margin_top = 100.0
margin_right = 120.0
margin_bottom = 125.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = true
@@ -109,8 +114,9 @@ shortcut = null
group = null
text = "Minimized"
flat = false
align = 1
[node name="Button_Maximized" type="Button" parent="Control"]
[node name="Button_Maximized" type="Button" parent="Control" index="3"]
anchor_left = 0.0
anchor_top = 0.0
@@ -121,8 +127,9 @@ margin_top = 140.0
margin_right = 120.0
margin_bottom = 165.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = true
@@ -131,8 +138,9 @@ shortcut = null
group = null
text = "Maximized"
flat = false
align = 1
[node name="Button_MoveTo" type="Button" parent="Control"]
[node name="Button_MoveTo" type="Button" parent="Control" index="4"]
anchor_left = 0.0
anchor_top = 0.0
@@ -143,8 +151,9 @@ margin_top = 178.0
margin_right = 120.0
margin_bottom = 203.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = false
@@ -153,8 +162,9 @@ shortcut = null
group = null
text = "MoveTo"
flat = false
align = 1
[node name="Button_Resize" type="Button" parent="Control"]
[node name="Button_Resize" type="Button" parent="Control" index="5"]
anchor_left = 0.0
anchor_top = 0.0
@@ -165,8 +175,9 @@ margin_top = 218.0
margin_right = 120.0
margin_bottom = 243.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = false
@@ -175,8 +186,9 @@ shortcut = null
group = null
text = "Resize"
flat = false
align = 1
[node name="Button_Screen0" type="Button" parent="Control"]
[node name="Button_Screen0" type="Button" parent="Control" index="6"]
anchor_left = 0.0
anchor_top = 0.0
@@ -187,8 +199,9 @@ margin_top = 258.0
margin_right = 120.0
margin_bottom = 283.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = false
@@ -197,8 +210,9 @@ shortcut = null
group = null
text = "Screen0"
flat = false
align = 1
[node name="Button_Screen1" type="Button" parent="Control"]
[node name="Button_Screen1" type="Button" parent="Control" index="7"]
anchor_left = 0.0
anchor_top = 0.0
@@ -209,8 +223,9 @@ margin_top = 298.0
margin_right = 120.0
margin_bottom = 323.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = false
@@ -219,8 +234,9 @@ shortcut = null
group = null
text = "Screen1"
flat = false
align = 1
[node name="Button_MouseModeVisible" type="Button" parent="Control"]
[node name="Button_MouseModeVisible" type="Button" parent="Control" index="8"]
anchor_left = 0.0
anchor_top = 1.0
@@ -231,8 +247,9 @@ margin_top = -221.0
margin_right = 225.0
margin_bottom = -196.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = true
@@ -243,7 +260,7 @@ text = "[F1] MOUSE_MODE_VISIBLE"
flat = false
align = 0
[node name="Button_MouseModeHidden" type="Button" parent="Control"]
[node name="Button_MouseModeHidden" type="Button" parent="Control" index="9"]
anchor_left = 0.0
anchor_top = 1.0
@@ -254,8 +271,9 @@ margin_top = -186.0
margin_right = 225.0
margin_bottom = -161.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = true
@@ -266,7 +284,7 @@ text = "[F2] MOUSE_MODE_HIDDEN"
flat = false
align = 0
[node name="Button_MouseModeCaptured" type="Button" parent="Control"]
[node name="Button_MouseModeCaptured" type="Button" parent="Control" index="10"]
anchor_left = 0.0
anchor_top = 1.0
@@ -277,8 +295,9 @@ margin_top = -151.0
margin_right = 225.0
margin_bottom = -126.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
focus_mode = 2
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
toggle_mode = true
@@ -289,7 +308,7 @@ text = "[F3] MOUSE_MODE_CAPTURED"
flat = false
align = 0
[node name="Label_Mode" type="Label" parent="Control"]
[node name="Label_Mode" type="Label" parent="Control" index="11"]
anchor_left = 1.0
anchor_top = 0.0
@@ -300,8 +319,8 @@ margin_top = 140.0
margin_right = -20.0
margin_bottom = 153.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Mode:"
@@ -309,7 +328,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Position" type="Label" parent="Control"]
[node name="Label_Position" type="Label" parent="Control" index="12"]
anchor_left = 1.0
anchor_top = 0.0
@@ -320,8 +339,8 @@ margin_top = 60.0
margin_right = -20.0
margin_bottom = 73.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Position:"
@@ -330,7 +349,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Size" type="Label" parent="Control"]
[node name="Label_Size" type="Label" parent="Control" index="13"]
anchor_left = 1.0
anchor_top = 0.0
@@ -341,8 +360,8 @@ margin_top = 100.0
margin_right = -20.0
margin_bottom = 113.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Size:"
@@ -351,7 +370,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_MousePosition" type="Label" parent="Control"]
[node name="Label_MousePosition" type="Label" parent="Control" index="14"]
anchor_left = 1.0
anchor_top = 0.0
@@ -362,8 +381,8 @@ margin_top = 220.0
margin_right = -20.0
margin_bottom = 153.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Mouse Position:"
@@ -371,19 +390,19 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen_Count" type="Label" parent="Control"]
[node name="Label_Screen_Count" type="Label" parent="Control" index="15"]
anchor_left = 1.0
anchor_top = 0.0
anchor_right = 1.0
anchor_bottom = 0.0
margin_left = -140.0
margin_top = 320.0
margin_top = 300.0
margin_right = -20.0
margin_bottom = 317.0
margin_bottom = 314.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen_Count:"
@@ -392,7 +411,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen_Current" type="Label" parent="Control"]
[node name="Label_Screen_Current" type="Label" parent="Control" index="16"]
anchor_left = 1.0
anchor_top = 0.0
@@ -403,8 +422,8 @@ margin_top = 20.0
margin_right = -20.0
margin_bottom = 40.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen:"
@@ -413,7 +432,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen0_Resolution" type="Label" parent="Control"]
[node name="Label_Screen0_Resolution" type="Label" parent="Control" index="17"]
anchor_left = 1.0
anchor_top = 0.0
@@ -424,8 +443,8 @@ margin_top = 340.0
margin_right = -16.0
margin_bottom = 353.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen0 Resolution: "
@@ -434,7 +453,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen0_Position" type="Label" parent="Control"]
[node name="Label_Screen0_Position" type="Label" parent="Control" index="18"]
anchor_left = 1.0
anchor_top = 0.0
@@ -445,8 +464,8 @@ margin_top = 380.0
margin_right = -16.0
margin_bottom = 396.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen0 Position: "
@@ -455,7 +474,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen0_DPI" type="Label" parent="Control"]
[node name="Label_Screen0_DPI" type="Label" parent="Control" index="19"]
anchor_left = 1.0
anchor_top = 0.0
@@ -466,8 +485,8 @@ margin_top = 416.0
margin_right = -16.0
margin_bottom = 432.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen0 DPI:"
@@ -476,7 +495,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen1_Resolution" type="Label" parent="Control"]
[node name="Label_Screen1_Resolution" type="Label" parent="Control" index="20"]
anchor_left = 1.0
anchor_top = 0.0
@@ -487,8 +506,8 @@ margin_top = 451.0
margin_right = -16.0
margin_bottom = 467.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen1 Resolution: "
@@ -497,7 +516,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen1_Position" type="Label" parent="Control"]
[node name="Label_Screen1_Position" type="Label" parent="Control" index="21"]
anchor_left = 1.0
anchor_top = 0.0
@@ -508,8 +527,8 @@ margin_top = 489.0
margin_right = -16.0
margin_bottom = 505.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen1 Position: "
@@ -518,7 +537,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_Screen1_DPI" type="Label" parent="Control"]
[node name="Label_Screen1_DPI" type="Label" parent="Control" index="22"]
anchor_left = 1.0
anchor_top = 0.0
@@ -529,8 +548,8 @@ margin_top = 524.0
margin_right = -16.0
margin_bottom = 540.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Screen1 DPI:"
@@ -539,7 +558,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_KeyInfo" type="Label" parent="Control"]
[node name="Label_KeyInfo" type="Label" parent="Control" index="23"]
anchor_left = 0.0
anchor_top = 1.0
@@ -550,8 +569,8 @@ margin_top = -122.0
margin_right = 286.0
margin_bottom = -63.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "F1: activate MOUSE_MODE_VISIBLE
@@ -562,7 +581,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_MouseModeCaptured_KeyInfo" type="Label" parent="Control"]
[node name="Label_MouseModeCaptured_KeyInfo" type="Label" parent="Control" index="24"]
anchor_left = 0.0
anchor_top = 1.0
@@ -573,8 +592,8 @@ margin_top = -65.0
margin_right = 286.0
margin_bottom = -11.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "ESC: deactivate MOUSE_MODE_CAPTURED
@@ -585,7 +604,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="Label_MouseModes" type="Label" parent="Control"]
[node name="Label_MouseModes" type="Label" parent="Control" index="25"]
anchor_left = 0.0
anchor_top = 1.0
@@ -596,8 +615,8 @@ margin_top = -249.0
margin_right = 286.0
margin_bottom = -227.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "MouseModes:"
@@ -606,7 +625,7 @@ percent_visible = 1.0
lines_skipped = 0
max_lines_visible = -1
[node name="ImplementationDialog" type="AcceptDialog" parent="Control"]
[node name="ImplementationDialog" type="AcceptDialog" parent="Control" index="26"]
visible = false
anchor_left = 0.0
@@ -618,8 +637,8 @@ margin_top = 100.0
margin_right = 600.0
margin_bottom = 450.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 0
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 2
popup_exclusive = false
@@ -627,7 +646,7 @@ window_title = "Please be advised..."
resizable = false
dialog_hide_on_ok = true
[node name="Text" type="Label" parent="Control/ImplementationDialog"]
[node name="Text" type="Label" parent="Control/ImplementationDialog" index="3"]
anchor_left = 0.0
anchor_top = 0.0
@@ -638,8 +657,8 @@ margin_top = 8.0
margin_right = 392.0
margin_bottom = 314.0
rect_pivot_offset = Vector2( 0, 0 )
rect_clip_content = false
mouse_filter = 2
mouse_default_cursor_shape = 0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "This is an Implementation-Test-Demo