Advertisement
jamesonBradfield

room_script.gd

Mar 6th, 2024 (edited)
793
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
GDScript 1.15 KB | Software | 0 0
  1. extends Node
  2.  
  3. @export var room_purpose : String
  4. @export var tiles : Array[Node]
  5. @export var bounds_cast : RayCast3D
  6. @export var width : float
  7. @export var length : float
  8.  
  9. func clear_room_purpose():
  10.     room_purpose = ""  
  11.  
  12. func set_bounds_cast():
  13.     var room_center = self.position
  14.     var half_width = round(room_center.distance_to(bounds_cast.get_collision_point()))
  15.     print("half_width : " + str(half_width))
  16.  
  17.  
  18. func create_trigger():
  19.     var raycast = RayCast3D.new()
  20.     var col = CollisionShape3D.new()   
  21.     add_child(col)
  22.     col.set_owner(owner)
  23.     add_child(raycast)
  24.     raycast.set_owner(owner)
  25.     raycast.name = "bounds_cast"
  26.     raycast.position = Vector3.ZERO
  27.     var box : Shape3D = BoxShape3D.new()
  28.     col.shape = box
  29.     col.name = "room_trigger"
  30.     col.position = Vector3.ZERO
  31.     bounds_cast = raycast
  32.  
  33. func set_children_as_tiles():
  34.     tiles = get_children()
  35.  
  36. func grab_room_data_and_setup_for_room_bounds():
  37.     clear_room_purpose()
  38.     set_children_as_tiles()
  39.     create_trigger()
  40.     set_bounds_cast()
  41.  
  42. func _ready():
  43.     var parent = get_parent()
  44.     print("room parent is : " + str(parent))
  45.     parent.connect("ready_room_for_bounds",grab_room_data_and_setup_for_room_bounds)
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement