Browse Source

Add head mesh to player scene, track camera

master
Luna 7 years ago
parent
commit
ff12a789f2
2 changed files with 38 additions and 13 deletions
  1. +37
    -12
      scenes/player.tscn
  2. +1
    -1
      scripts/player.gd

+ 37
- 12
scenes/player.tscn View File

@ -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/player.gd" type="Script" id=1]
[ext_resource path="res://scripts/tp_camera.gd" type="Script" id=2] [ext_resource path="res://scripts/tp_camera.gd" type="Script" id=2]
@ -13,10 +13,18 @@ height = 0.5
length = 0.3 length = 0.3
_sections_unfolded = [ "Resource" ] _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] [sub_resource type="CapsuleMesh" id=3]
radius = 0.4 radius = 0.4
mid_height = 0.5
mid_height = 0.1
radial_segments = 64 radial_segments = 64
rings = 8 rings = 8
_sections_unfolded = [ "Resource" ] _sections_unfolded = [ "Resource" ]
@ -78,9 +86,16 @@ cast_to = Vector3( 0, -0.3, 0 )
collision_mask = 1 collision_mask = 1
_sections_unfolded = [ "Transform", "Visibility" ] _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 layers = 1
material_override = null material_override = null
cast_shadow = 1 cast_shadow = 1
@ -90,19 +105,29 @@ lod_min_distance = 0.0
lod_min_hysteresis = 0.0 lod_min_hysteresis = 0.0
lod_max_distance = 0.0 lod_max_distance = 0.0
lod_max_hysteresis = 0.0 lod_max_hysteresis = 0.0
mesh = SubResource( 3 )
mesh = SubResource( 4 )
skeleton = NodePath("..") skeleton = NodePath("..")
material/0 = null material/0 = null
_sections_unfolded = [ "Transform" ] _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" ] _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"] [node name="Crosshair" type="Label" parent="MasterOnly" index="0"]
@ -146,9 +171,9 @@ percent_visible = 1.0
lines_skipped = 0 lines_skipped = 0
max_lines_visible = -1 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 ) script = ExtResource( 2 )
_sections_unfolded = [ "Transform" ] _sections_unfolded = [ "Transform" ]
cam = NodePath("Camera") cam = NodePath("Camera")


+ 1
- 1
scripts/player.gd View File

@ -74,7 +74,7 @@ func toggle_mouse_capture():
# Update visual yaw + pitch components to match camera # Update visual yaw + pitch components to match camera
func set_rotation(): func set_rotation():
get_node("Yaw").set_rotation(Vector3(0, deg2rad(get_node(tp_camera).cam_yaw), 0)) 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): func _integrate_forces(state):
if is_network_master(): if is_network_master():


Loading…
Cancel
Save