31 lines
864 B
GDScript
31 lines
864 B
GDScript
@tool
|
|
class_name Bridge extends Area2D
|
|
## Disable the collisions when player enter
|
|
|
|
var wallObjects : Array
|
|
|
|
func _init():
|
|
collision_layer = 4
|
|
collision_mask = 25
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready():
|
|
body_entered.connect(_on_body_entered)
|
|
body_exited.connect(_on_body_exited)
|
|
|
|
|
|
|
|
func _on_body_entered(object):
|
|
print("Entered %d",object)
|
|
if (object.has_meta("Type") and object.get_meta("Type") == "Player" and wallObjects != null ):
|
|
for _object in wallObjects:
|
|
if (_object != null):
|
|
_object.process_mode = Node.PROCESS_MODE_DISABLED
|
|
else:
|
|
wallObjects.append(object)
|
|
|
|
|
|
func _on_body_exited(object):
|
|
if (object.has_meta("Type") and object.get_meta("Type") == "Player" and wallObjects != null ):
|
|
for _object in wallObjects:
|
|
if (_object != null):
|
|
_object.process_mode = Node.PROCESS_MODE_INHERIT
|