You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This could help a lot and could be used trough a component. It can be used to define areas as safe/unsafe or other things like a boss area with special properties. This component could be used both on a character as a detector or in the world as a designator.
Either by using a combo of 2 different components or a single one that can switch between detecting and simply being a designated area.
For a single object, the script could be something like this (leaving as reference for later mostly):
extends Area2D
class_name AreaDesignationComponent
signal area_detected(type: String)
enum Modes { DESIGNATOR, DETECTOR }
@export var mode: Modes
@export var area_type: String
var overlappingTypes: Array[String]
func _init():
collision_mask = J.AREA_LAYER
collision_layer = J.AREA_LAYER
if mode == Modes.DETECTOR:
body_entered.connect(_on_body_entered_detector)
body_exited.connect(_on_body_exited_detector)
func update_mode():
if mode == Modes.DESIGNATOR:
monitoreable = true
monitoring = false
elif mode == Modes.DETECTOR:
monitoreable = false
monitoring = true
func detector_get_areas() -> Array[String]:
return overlappingTypes
func _on_body_entered_detector(body: Node):
if body is AreaDesignationComponent and not body.area_type in overlappingTypes:
overlappingTypes.append(body.area_type)
area_detected.emit(body.area_type)
func _on_body_exited_detector(body: Node):
if body is AreaDesignationComponent:
overlappingTypes.erase(body.area_type)
Telling enemies which areas they can and cannot wander towards.
Defining zones where the player is considered as "safe" and can do actions that would otherwise be locked.
For quests that randomize locations of objectives, an area can be defined instead.
Informing players of their current area.
Defining where PvP can be performed.
As i proposed before, these areas would be little more than an Area2D with an Array[String]. Each component/script would be in charge of interpreting each String as they see fit.
For example, the code for allowing changing selected skills, would check if the player's current position touches an area with the "safe" tag
This could help a lot and could be used trough a component. It can be used to define areas as safe/unsafe or other things like a boss area with special properties. This component could be used both on a character as a detector or in the world as a designator.
Either by using a combo of 2 different components or a single one that can switch between detecting and simply being a designated area.
For a single object, the script could be something like this (leaving as reference for later mostly):
Or this:
The text was updated successfully, but these errors were encountered: