godot_tiny_crate/Script/Box.gd
Harmony Monroe 3e79a48d37 using groups
2020-08-23 18:00:29 -04:00

35 lines
685 B
GDScript3

extends Actor
class_name Box
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
var is_pushed = false
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
if speed_x != 0 and is_on_floor:
speed_x = 0
is_pushed = false
# push box
func push(dir : int):
if not check_solid_x(dir):
#is_pushed = true
#speed_x = dir
for a in overlapping_actors(0, -1, null):
if a.tag == "box":
a.push(dir)
# only be pushed by one crate
# if not a.is_pushed:
# a.push(dir)
move_x(dir)