tweaked collision layers in hallways

added hidden torch to player
added ability to get/place torches in holders
added raycast to player
master
Zac 4 years ago
parent e490e4acc6
commit c5a62b576a
  1. 1
      _scenes/pieces/deadend.tscn
  2. 1
      _scenes/pieces/hallway.tscn
  3. 1
      _scenes/pieces/hallway_w_torch.tscn
  4. 16
      _scenes/pieces/player.tscn
  5. 54
      _scenes/pieces/torch.tscn
  6. 37
      _scenes/pieces/torch_holder.tscn
  7. 15
      scripts/player.gd
  8. 19
      scripts/torch.gd

@ -28,6 +28,7 @@ transform = Transform( 1.33034, 0, 0, 0, 1.16516, 0, 0, 0, 1.33034, 3.65142, 3.7
transform = Transform( 1.33034, 0, 0, 0, 1.16516, 0, 0, 0, 1.33034, 3.65142, 3.71428, 3.58174 )
[node name="collision" type="StaticBody" parent="." index="5"]
collision_layer = 2
[node name="CollisionShape" type="CollisionShape" parent="collision" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 4, 3.66364, 0 )

@ -20,6 +20,7 @@ material/0 = ExtResource( 3 )
material/0 = ExtResource( 4 )
[node name="StaticBody" type="StaticBody" parent="." index="3"]
collision_layer = 2
[node name="CollisionShape" type="CollisionShape" parent="StaticBody" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, -4 )

@ -22,6 +22,7 @@ material/0 = ExtResource( 4 )
[node name="StaticBody" type="StaticBody" parent="." index="3"]
editor/display_folded = true
collision_layer = 2
[node name="CollisionShape" type="CollisionShape" parent="StaticBody" index="0"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, -4 )

@ -1,15 +1,15 @@
[gd_scene load_steps=4 format=2]
[gd_scene load_steps=5 format=2]
[ext_resource path="res://scripts/player.gd" type="Script" id=1]
[ext_resource path="res://assets/camera_env.tres" type="Environment" id=2]
[ext_resource path="res://_scenes/pieces/torch.tscn" type="PackedScene" id=3]
[sub_resource type="CapsuleShape" id=1]
radius = 0.912697
height = 3.8991
[node name="player" type="KinematicBody"]
collision_mask = 2
collision_mask = 6
script = ExtResource( 1 )
[node name="CollisionShape" type="CollisionShape" parent="."]
@ -25,3 +25,13 @@ environment = ExtResource( 2 )
current = true
near = 0.01
far = 360.7
[node name="RayCast" type="RayCast" parent="Head/Camera"]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 0, -0.819098 )
enabled = true
cast_to = Vector3( 0, -2, 0 )
collision_mask = 4
[node name="torch" parent="Head" instance=ExtResource( 3 )]
transform = Transform( 0.0871558, 1.49012e-008, -0.996195, 0.49454, 0.868078, 0.0432666, 0.864774, -0.496429, 0.075658, -0.875688, -2.20227, -1.95269 )
visible = false

@ -7,7 +7,7 @@
[ext_resource path="res://textures/fire/fire_01.png" type="Texture" id=5]
[ext_resource path="res://textures/fire/smoke_04.png" type="Texture" id=6]
[sub_resource type="SpatialMaterial" id=1]
[sub_resource type="SpatialMaterial" id=2]
albedo_texture = ExtResource( 2 )
metallic_specular = 0.0
normal_enabled = true
@ -19,19 +19,19 @@ ao_texture = ExtResource( 3 )
ao_on_uv2 = false
ao_texture_channel = 0
[sub_resource type="Gradient" id=2]
[sub_resource type="Gradient" id=3]
colors = PoolColorArray( 0.933333, 0.811765, 0.529412, 1, 0.987793, 0.846993, 0.0694542, 1 )
[sub_resource type="GradientTexture" id=3]
gradient = SubResource( 2 )
[sub_resource type="GradientTexture" id=4]
gradient = SubResource( 3 )
[sub_resource type="Curve" id=4]
[sub_resource type="Curve" id=5]
_data = [ Vector2( 0, 0 ), 0.0, 0.0, 0, 0, Vector2( 0.273551, 0.9026 ), 0.0, 0.0, 0, 0, Vector2( 1, 0 ), 0.0, 0.0, 0, 0 ]
[sub_resource type="CurveTexture" id=5]
curve = SubResource( 4 )
[sub_resource type="CurveTexture" id=6]
curve = SubResource( 5 )
[sub_resource type="ParticlesMaterial" id=6]
[sub_resource type="ParticlesMaterial" id=7]
emission_shape = 1
emission_sphere_radius = 0.3
spread = 0.0
@ -42,10 +42,10 @@ linear_accel = 4.0
angle = 360.0
angle_random = 1.0
scale = 2.0
scale_curve = SubResource( 5 )
color_ramp = SubResource( 3 )
scale_curve = SubResource( 6 )
color_ramp = SubResource( 4 )
[sub_resource type="SpatialMaterial" id=7]
[sub_resource type="SpatialMaterial" id=8]
flags_unshaded = true
vertex_color_use_as_albedo = true
params_blend_mode = 1
@ -58,17 +58,17 @@ distance_fade_mode = 1
distance_fade_min_distance = 0.0
distance_fade_max_distance = 10.0
[sub_resource type="QuadMesh" id=8]
material = SubResource( 7 )
[sub_resource type="QuadMesh" id=9]
material = SubResource( 8 )
[sub_resource type="Gradient" id=9]
[sub_resource type="Gradient" id=10]
offsets = PoolRealArray( 0, 0.507157, 1 )
colors = PoolColorArray( 0, 0, 0, 0, 0.556237, 0.556237, 0.556237, 1, 1, 1, 1, 0 )
[sub_resource type="GradientTexture" id=10]
gradient = SubResource( 9 )
[sub_resource type="GradientTexture" id=11]
gradient = SubResource( 10 )
[sub_resource type="ParticlesMaterial" id=11]
[sub_resource type="ParticlesMaterial" id=12]
emission_shape = 1
emission_sphere_radius = 0.3
spread = 0.0
@ -78,10 +78,10 @@ angular_velocity_random = 1.0
linear_accel = 4.0
angle = 360.0
angle_random = 1.0
scale_curve = SubResource( 5 )
color_ramp = SubResource( 10 )
scale_curve = SubResource( 6 )
color_ramp = SubResource( 11 )
[sub_resource type="SpatialMaterial" id=12]
[sub_resource type="SpatialMaterial" id=13]
flags_transparent = true
flags_unshaded = true
vertex_color_use_as_albedo = true
@ -92,15 +92,15 @@ particles_anim_v_frames = 1
particles_anim_loop = false
albedo_texture = ExtResource( 6 )
[sub_resource type="QuadMesh" id=13]
material = SubResource( 12 )
[sub_resource type="QuadMesh" id=14]
material = SubResource( 13 )
[node name="torch" type="Spatial"]
[node name="MeshInstance" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.104118, 0 )
mesh = ExtResource( 1 )
material/0 = SubResource( 1 )
material/0 = SubResource( 2 )
[node name="fire" type="Spatial" parent="."]
@ -156,8 +156,8 @@ amount = 20
preprocess = 4.7
randomness = 1.0
local_coords = false
process_material = SubResource( 6 )
draw_pass_1 = SubResource( 8 )
process_material = SubResource( 7 )
draw_pass_1 = SubResource( 9 )
[node name="smoke" type="Particles" parent="fire"]
transform = Transform( 1, 0, 0, 0, -1, 8.74228e-008, 0, -8.74228e-008, -1, 0.0386006, 1.97399, 0.0386426 )
@ -166,5 +166,5 @@ lifetime = 1.5
preprocess = 41.2
randomness = 1.0
local_coords = false
process_material = SubResource( 11 )
draw_pass_1 = SubResource( 13 )
process_material = SubResource( 12 )
draw_pass_1 = SubResource( 14 )

@ -1,36 +1,41 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://models/torch_holder.obj" type="ArrayMesh" id=1]
[ext_resource path="res://textures/torch holder/torch_holder_AlbedoTransparency.png" type="Texture" id=2]
[ext_resource path="res://textures/torch holder/torch_holder_AO.png" type="Texture" id=3]
[ext_resource path="res://textures/torch holder/torch_holder_MetallicSmoothness.png" type="Texture" id=4]
[ext_resource path="res://textures/torch holder/torch_holder_Normal.png" type="Texture" id=5]
[ext_resource path="res://_scenes/pieces/torch.tscn" type="PackedScene" id=6]
[ext_resource path="res://scripts/torch.gd" type="Script" id=1]
[ext_resource path="res://models/torch_holder.obj" type="ArrayMesh" id=2]
[ext_resource path="res://textures/torch holder/torch_holder_AlbedoTransparency.png" type="Texture" id=3]
[ext_resource path="res://textures/torch holder/torch_holder_AO.png" type="Texture" id=4]
[ext_resource path="res://textures/torch holder/torch_holder_MetallicSmoothness.png" type="Texture" id=5]
[ext_resource path="res://textures/torch holder/torch_holder_Normal.png" type="Texture" id=6]
[ext_resource path="res://_scenes/pieces/torch.tscn" type="PackedScene" id=7]
[sub_resource type="SpatialMaterial" id=1]
albedo_texture = ExtResource( 2 )
albedo_texture = ExtResource( 3 )
metallic = 0.57
metallic_specular = 0.37
metallic_texture = ExtResource( 4 )
metallic_texture = ExtResource( 5 )
metallic_texture_channel = 3
normal_enabled = true
normal_scale = 1.0
normal_texture = ExtResource( 5 )
normal_texture = ExtResource( 6 )
ao_enabled = true
ao_light_affect = 0.66
ao_texture = ExtResource( 3 )
ao_texture = ExtResource( 4 )
ao_on_uv2 = false
ao_texture_channel = 0
[sub_resource type="BoxShape" id=2]
extents = Vector3( 0.643394, 1.21763, 0.753165 )
[node name="holder" type="Spatial"]
transform = Transform( 0.73, 0, 0, 0, 0.73, 0, 0, 0, 0.73, 0, 0, 0 )
script = ExtResource( 1 )
[node name="torch_holder" type="MeshInstance" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1, 0 )
mesh = ExtResource( 1 )
mesh = ExtResource( 2 )
material/0 = SubResource( 1 )
[node name="torch" parent="." instance=ExtResource( 6 )]
[node name="torch" parent="." instance=ExtResource( 7 )]
transform = Transform( 1, 0, 0, 0, 0.958212, 0.286058, 0, -0.286058, 0.958212, 0, -0.82, 0 )
[node name="SpotLight" type="SpotLight" parent="."]
@ -38,3 +43,9 @@ transform = Transform( 0.354547, 0.598061, 1.18032, 0, -1.22195, 0.619158, 1.323
light_energy = 16.0
editor_only = true
[node name="StaticBody" type="StaticBody" parent="."]
collision_layer = 4
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.114504, -0.21646 )
shape = SubResource( 2 )

@ -5,13 +5,21 @@ const SENSITIVITY = 0.2
onready var camera = $Head/Camera
onready var head = $Head
onready var ray = $Head/Camera/RayCast
onready var torch = $Head/torch
var camera_x_rot = 0
var holder = null
func _ready():
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
func _physics_process(delta):
if ray.is_colliding():
holder = ray.get_collider().get_parent()
else:
holder = null
var vel = Vector3()
if Input.is_action_pressed("player_foward"):
vel += -head.transform.basis.x
@ -32,4 +40,9 @@ func _input(event):
var x_change = -event.relative.y * SENSITIVITY
if x_change + camera_x_rot < 90 and x_change + camera_x_rot > -90:
camera.rotate_x(deg2rad(x_change))
camera_x_rot += x_change
camera_x_rot += x_change
elif event is InputEventMouseButton and event.is_pressed() and holder != null:
if torch.visible and holder.place_torch():
torch.hide()
elif not torch.visible and holder.get_torch():
torch.show()

@ -0,0 +1,19 @@
extends Spatial
onready var torch = $torch
var placed = true
func get_torch():
if placed:
torch.hide()
placed = not placed
return true
return false
func place_torch():
if not placed:
torch.show()
placed = not placed
return true
return false
Loading…
Cancel
Save