starcheese/hardpoint.gd

20 lines
740 B
GDScript3
Raw Normal View History

2024-10-01 16:43:34 +02:00
extends Node2D
@export var hardpoint_id: String = "HardPoint1" # Unique identifier for this hardpoint
# Optional - can store a reference to the mounted weapon
var mounted_weapon: Node2D = null
# Method to attach a weapon to the hardpoint
func attach_weapon(weapon: Node2D) -> void:
mounted_weapon = weapon
weapon.global_position = global_position # Set weapon position to the hardpoint position
weapon.rotation = rotation # Align the weapon's rotation to the hardpoint's rotation
func _draw():
draw_circle(Vector2.ZERO, 10, Color(1, 0, 0)) # Draw a red circle at the hardpoint
func _ready():
add_to_group("hardpoints") # Add the hardpoint to the "hardpoints" group
queue_redraw() # Redraw the visual to ensure it's updated