Early switch scripts working
This commit is contained in:
@@ -81,7 +81,7 @@ shadow_mesh = SubResource("ArrayMesh_nxwjy")
|
|||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_kg5u6"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_kg5u6"]
|
||||||
size = Vector3(2.10059, 1.23395, 0.909241)
|
size = Vector3(2.10059, 1.23395, 0.909241)
|
||||||
|
|
||||||
[node name="Boombox" type="RigidBody3D" groups=["breakable", "scene_rigidbody"]]
|
[node name="Boombox" type="RigidBody3D" groups=["breakable", "interact", "scene_rigidbody"]]
|
||||||
collision_layer = 32
|
collision_layer = 32
|
||||||
collision_mask = 125
|
collision_mask = 125
|
||||||
continuous_cd = true
|
continuous_cd = true
|
||||||
|
|||||||
@@ -1184,6 +1184,7 @@ mesh = SubResource("ArrayMesh_ahftj")
|
|||||||
|
|
||||||
[node name="flare" type="MeshInstance3D" parent="revolver1" index="3"]
|
[node name="flare" type="MeshInstance3D" parent="revolver1" index="3"]
|
||||||
transform = Transform3D(-2.72424e-08, 0.381822, -1.11212e-08, 6.77626e-21, -1.66903e-08, -0.254424, -0.623234, -1.669e-08, 4.86124e-16, -0.109069, 0.0424353, -2.70625)
|
transform = Transform3D(-2.72424e-08, 0.381822, -1.11212e-08, 6.77626e-21, -1.66903e-08, -0.254424, -0.623234, -1.669e-08, 4.86124e-16, -0.109069, 0.0424353, -2.70625)
|
||||||
|
visible = false
|
||||||
transparency = 1.0
|
transparency = 1.0
|
||||||
cast_shadow = 0
|
cast_shadow = 0
|
||||||
mesh = SubResource("ArrayMesh_t14cq")
|
mesh = SubResource("ArrayMesh_t14cq")
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
15
levels/switch_target.gd
Normal file
15
levels/switch_target.gd
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
extends StaticBody3D
|
||||||
|
|
||||||
|
signal switch_hit()
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass # Replace with function body.
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func hit():
|
||||||
|
emit_signal("switch_hit")
|
||||||
13
levels/switchcontroller.gd
Normal file
13
levels/switchcontroller.gd
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
extends Node
|
||||||
|
|
||||||
|
@export var door : Node
|
||||||
|
@export var switch : Node
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
if switch.switched_on:
|
||||||
|
door.state_change(switch.switched_on)
|
||||||
@@ -75,5 +75,9 @@ func _process(delta):
|
|||||||
hit_indicator.play()
|
hit_indicator.play()
|
||||||
enemy_particles.emitting = true
|
enemy_particles.emitting = true
|
||||||
ray.get_collider().hit(bullet_damage)
|
ray.get_collider().hit(bullet_damage)
|
||||||
|
|
||||||
|
if ray.get_collider().is_in_group("switch"):
|
||||||
|
ray.get_collider().hit()
|
||||||
|
|
||||||
await get_tree().create_timer(1.0).timeout
|
await get_tree().create_timer(1.0).timeout
|
||||||
queue_free()
|
queue_free()
|
||||||
|
|||||||
33
scripts/door.gd
Normal file
33
scripts/door.gd
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
extends MeshInstance3D
|
||||||
|
|
||||||
|
@export var anim_player : Node
|
||||||
|
@export var door_open_start : bool = false
|
||||||
|
var door_open : bool
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
door_open = door_open_start
|
||||||
|
|
||||||
|
if door_open:
|
||||||
|
open()
|
||||||
|
else:
|
||||||
|
close()
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func open():
|
||||||
|
anim_player.play("open")
|
||||||
|
|
||||||
|
func close():
|
||||||
|
anim_player.play("close")
|
||||||
|
|
||||||
|
func state_change(switch_on):
|
||||||
|
if door_open != switch_on:
|
||||||
|
if switch_on:
|
||||||
|
door_open = true
|
||||||
|
open()
|
||||||
|
else:
|
||||||
|
door_open = false
|
||||||
|
close()
|
||||||
@@ -203,7 +203,7 @@ func _physics_process(delta):
|
|||||||
#cache fastest speed
|
#cache fastest speed
|
||||||
if abs(velocity.y) > moving_fast_top_speed:
|
if abs(velocity.y) > moving_fast_top_speed:
|
||||||
moving_fast_top_speed = abs(velocity.y)
|
moving_fast_top_speed = abs(velocity.y)
|
||||||
print("TOP SPEED = " + str(moving_fast_top_speed))
|
#print("TOP SPEED = " + str(moving_fast_top_speed))
|
||||||
#Land Sound
|
#Land Sound
|
||||||
if velocity.y < .1 and self.is_on_floor() and moving_fast == true:
|
if velocity.y < .1 and self.is_on_floor() and moving_fast == true:
|
||||||
print("LAND SOUND")
|
print("LAND SOUND")
|
||||||
|
|||||||
47
scripts/switch_interactandshoot.gd
Normal file
47
scripts/switch_interactandshoot.gd
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
extends Node3D
|
||||||
|
|
||||||
|
var switched_on
|
||||||
|
|
||||||
|
@export var default_setting : bool = false
|
||||||
|
@export var toggle_enabled : bool = false
|
||||||
|
@export var bullet_enabled : bool = true
|
||||||
|
@export var timer_enabled : bool = false
|
||||||
|
@export var timer_duration : float = 2.0
|
||||||
|
|
||||||
|
|
||||||
|
# Called when the node enters the scene tree for the first time.
|
||||||
|
func _ready() -> void:
|
||||||
|
add_to_group("switch")
|
||||||
|
add_to_group("interact")
|
||||||
|
switched_on = default_setting
|
||||||
|
|
||||||
|
|
||||||
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func interact():
|
||||||
|
print("switch hit")
|
||||||
|
if toggle_enabled:
|
||||||
|
if switched_on:
|
||||||
|
switched_on = false
|
||||||
|
else:
|
||||||
|
switched_on = true
|
||||||
|
else:
|
||||||
|
print("switched on")
|
||||||
|
switched_on = true
|
||||||
|
|
||||||
|
|
||||||
|
func _on_static_body_3d_switch_hit() -> void:
|
||||||
|
if bullet_enabled:
|
||||||
|
print("switch hit")
|
||||||
|
if toggle_enabled:
|
||||||
|
if switched_on:
|
||||||
|
switched_on = false
|
||||||
|
else:
|
||||||
|
print("switched on")
|
||||||
|
switched_on = true
|
||||||
|
else:
|
||||||
|
print("switched on")
|
||||||
|
switched_on = true
|
||||||
|
|
||||||
Reference in New Issue
Block a user