From ff12a789f22bd139ce2854e4ce52143bc509de96 Mon Sep 17 00:00:00 2001 From: Luna Date: Sat, 3 Feb 2018 16:25:07 -0500 Subject: [PATCH] Add head mesh to player scene, track camera --- scenes/player.tscn | 49 +++++++++++++++++++++++++++++++++++++------------ scripts/player.gd | 2 +- 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/scenes/player.tscn b/scenes/player.tscn index 2360b77..ff3f514 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=6 format=2] +[gd_scene load_steps=7 format=2] [ext_resource path="res://scripts/player.gd" type="Script" id=1] [ext_resource path="res://scripts/tp_camera.gd" type="Script" id=2] @@ -13,10 +13,18 @@ height = 0.5 length = 0.3 _sections_unfolded = [ "Resource" ] +[sub_resource type="PrismMesh" id=4] + +left_to_right = 0.5 +size = Vector3( 0.5, 0.5, 0.5 ) +subdivide_width = 0 +subdivide_height = 0 +subdivide_depth = 0 + [sub_resource type="CapsuleMesh" id=3] radius = 0.4 -mid_height = 0.5 +mid_height = 0.1 radial_segments = 64 rings = 8 _sections_unfolded = [ "Resource" ] @@ -78,9 +86,16 @@ cast_to = Vector3( 0, -0.3, 0 ) collision_mask = 1 _sections_unfolded = [ "Transform", "Visibility" ] -[node name="MeshInstance" type="MeshInstance" parent="." index="3"] +[node name="Yaw" type="Spatial" parent="." index="3"] -transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.95, 0 ) +[node name="Pitch" type="Spatial" parent="Yaw" index="0"] + +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4, 0 ) +_sections_unfolded = [ "Transform" ] + +[node name="MeshInstance" type="MeshInstance" parent="Yaw/Pitch" index="0"] + +transform = Transform( 2.65431e-14, -1.62921e-07, 1, -1, -1.62921e-07, 0, 1.62921e-07, -1, -1.62921e-07, 0, -0.0649133, -0.103671 ) layers = 1 material_override = null cast_shadow = 1 @@ -90,19 +105,29 @@ lod_min_distance = 0.0 lod_min_hysteresis = 0.0 lod_max_distance = 0.0 lod_max_hysteresis = 0.0 -mesh = SubResource( 3 ) +mesh = SubResource( 4 ) skeleton = NodePath("..") material/0 = null _sections_unfolded = [ "Transform" ] -[node name="Yaw" type="Spatial" parent="." index="4"] +[node name="MeshInstance" type="MeshInstance" parent="Yaw" index="1"] -[node name="Pitch" type="Spatial" parent="Yaw" index="0"] - -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4, 0 ) +transform = Transform( 1, 0, 0, 0, -1.62921e-07, -1, 0, 1, -1.62921e-07, 0, 0.787368, 0 ) +layers = 1 +material_override = null +cast_shadow = 1 +extra_cull_margin = 0.0 +use_in_baked_light = false +lod_min_distance = 0.0 +lod_min_hysteresis = 0.0 +lod_max_distance = 0.0 +lod_max_hysteresis = 0.0 +mesh = SubResource( 3 ) +skeleton = NodePath("..") +material/0 = null _sections_unfolded = [ "Transform" ] -[node name="MasterOnly" type="Node" parent="." index="5"] +[node name="MasterOnly" type="Node" parent="." index="4"] [node name="Crosshair" type="Label" parent="MasterOnly" index="0"] @@ -146,9 +171,9 @@ percent_visible = 1.0 lines_skipped = 0 max_lines_visible = -1 -[node name="TPCamera" type="Spatial" parent="." index="6"] +[node name="TPCamera" type="Spatial" parent="." index="5"] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.4, 0 ) +transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.74343, 0 ) script = ExtResource( 2 ) _sections_unfolded = [ "Transform" ] cam = NodePath("Camera") diff --git a/scripts/player.gd b/scripts/player.gd index 1a9b24a..e8ff589 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -74,7 +74,7 @@ func toggle_mouse_capture(): # Update visual yaw + pitch components to match camera func set_rotation(): get_node("Yaw").set_rotation(Vector3(0, deg2rad(get_node(tp_camera).cam_yaw), 0)) - get_node("Yaw/Pitch").set_rotation(Vector3(deg2rad(get_node(tp_camera).cam_pitch), 0, 0)) + get_node("Yaw/Pitch").set_rotation(Vector3(deg2rad(-get_node(tp_camera).cam_pitch), 0, 0)) func _integrate_forces(state): if is_network_master():