Collision also changes depending on pill status
Corresponds to visibility
This commit is contained in:
parent
09e0f32503
commit
92c8e66e63
@ -5,4 +5,6 @@ onready var screen_texture = get_node("ScreenTexture") as ColorRect
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
screen_texture.material.set_shader_param("mask_factor", Pills.get_level() / Pills.get_max())
|
||||
# The factor is 0 when the level is between 0% and 20%; 1 when the level is between 80% and 100%; lerp inbetween
|
||||
var factor = clamp((Pills.get_level() / Pills.get_max() * 1.4 - 0.2), 0.0, 1.0)
|
||||
screen_texture.material.set_shader_param("mask_factor", factor)
|
@ -54,6 +54,7 @@ func _ready():
|
||||
func _physics_process(delta):
|
||||
process_input()
|
||||
process_movement(delta)
|
||||
process_collision_layers()
|
||||
|
||||
func _process(_delta):
|
||||
check_interact()
|
||||
@ -102,6 +103,18 @@ func process_animations():
|
||||
_animation.playback_speed = _vel.length() / MOVE_SPEED
|
||||
|
||||
|
||||
func process_collision_layers():
|
||||
var new_layer: int = 6
|
||||
|
||||
if Pills.get_level() >= Pills.LEVELS.LOW:
|
||||
# If the masked view is almost invisible, collision with masked objects is disabled
|
||||
new_layer -= 1 # See collision layer names in editor
|
||||
|
||||
print(new_layer)
|
||||
collision_layer = new_layer
|
||||
collision_mask = new_layer
|
||||
|
||||
|
||||
func check_interact():
|
||||
if _lookCast.is_colliding():
|
||||
var collider = _lookCast.get_collider()
|
||||
|
@ -66,8 +66,8 @@ random_pitch = 1.3
|
||||
[node name="Player" type="KinematicBody" groups=[
|
||||
"Player",
|
||||
]]
|
||||
collision_layer = 5
|
||||
collision_mask = 5
|
||||
collision_layer = 7
|
||||
collision_mask = 7
|
||||
script = ExtResource( 1 )
|
||||
body_nodepath = NodePath("Body")
|
||||
lookingAt_nodepath = NodePath("Body/PillCameras/LookingAt")
|
||||
|
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=3 format=2]
|
||||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[sub_resource type="CubeMesh" id=1]
|
||||
size = Vector3( 26, 12, 14 )
|
||||
@ -6,9 +6,17 @@ size = Vector3( 26, 12, 14 )
|
||||
[sub_resource type="SpatialMaterial" id=2]
|
||||
albedo_color = Color( 1, 0.917647, 0.537255, 1 )
|
||||
|
||||
[sub_resource type="ConcavePolygonShape" id=3]
|
||||
data = PoolVector3Array( -13, 6, 7, 13, 6, 7, -13, -6, 7, 13, 6, 7, 13, -6, 7, -13, -6, 7, 13, 6, -7, -13, 6, -7, 13, -6, -7, -13, 6, -7, -13, -6, -7, 13, -6, -7, 13, 6, 7, 13, 6, -7, 13, -6, 7, 13, 6, -7, 13, -6, -7, 13, -6, 7, -13, 6, -7, -13, 6, 7, -13, -6, -7, -13, 6, 7, -13, -6, 7, -13, -6, -7, 13, 6, 7, -13, 6, 7, 13, 6, -7, -13, 6, 7, -13, 6, -7, 13, 6, -7, -13, -6, 7, 13, -6, 7, -13, -6, -7, 13, -6, 7, 13, -6, -7, -13, -6, -7 )
|
||||
|
||||
[node name="BuildingBlock" type="Spatial"]
|
||||
|
||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
|
||||
mesh = SubResource( 1 )
|
||||
material/0 = SubResource( 2 )
|
||||
|
||||
[node name="StaticBody" type="StaticBody" parent="MeshInstance"]
|
||||
|
||||
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"]
|
||||
shape = SubResource( 3 )
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user