Early switch scripts working
This commit is contained in:
@@ -75,5 +75,9 @@ func _process(delta):
|
||||
hit_indicator.play()
|
||||
enemy_particles.emitting = true
|
||||
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
|
||||
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
|
||||
if abs(velocity.y) > moving_fast_top_speed:
|
||||
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
|
||||
if velocity.y < .1 and self.is_on_floor() and moving_fast == true:
|
||||
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