🇩🇪 Interaktionsradius-System – Funktionsweise
Dieses System sorgt dafür, dass ein Spieler erkennt, wenn er sich in der Nähe eines interagierbaren NPCs befindet. Es bildet die Grundlage für Dialoge, Shops oder andere Interaktionen.
🔹 Aufbau
Jeder NPC besitzt eine Interaction Component, die automatisch einen unsichtbaren Interaktionsradius um den NPC erzeugt. Dieser Radius ist eine Sphere Collision, die nur auf den Spieler reagiert.
Der Radius ist pro NPC im Level einstellbar, sodass man z. B. größere Abstände verwenden kann, wenn ein Tisch oder ein Hindernis zwischen Spieler und NPC steht.
⸻
🔹 Was passiert technisch?
1. NPC hat eine Interaction Component
• Beim Start des Spiels erzeugt diese Component eine Sphere Collision.
• Der Radius dieser Sphere wird über die Variable InteractionRadius festgelegt.
2. Der Spieler betritt den Radius
• Die Sphere löst ein Begin Overlap aus.
• Die Component prüft, ob der überlappende Actor das Interaktions-Interface besitzt.
• Falls ja, wird die Interface-Funktion PlayerInRange beim Spieler aufgerufen.
• Der Spieler setzt intern:
• bCanInteract = true
• CurrentInteractable = dieser NPC
3. Der Spieler verlässt den Radius
• Die Sphere löst ein End Overlap aus.
• Wieder wird über das Interface kommuniziert.
• PlayerOutOfRange wird beim Spieler aufgerufen.
• Der Spieler setzt:
• bCanInteract = false
• CurrentInteractable = None
⸻
🔹 Warum ein Interface?
Das Interface sorgt dafür, dass das System nicht vom konkreten Spielertyp abhängt. Egal welcher Character oder welche Klasse gesteuert wird — solange das Interface implementiert ist, funktioniert die Interaktion.
Das macht das System:
• modular
• wiederverwendbar
• multiplayer-tauglich
⸻
🔹 Ergebnis
Sobald sich der Spieler im Interaktionsradius eines NPCs befindet, weiß der Spieler:
„Ich kann mit diesem NPC interagieren.“
Dieses Signal wird später verwendet, um:
• Dialoge zu starten
• Händler zu öffnen
• Quests auszulösen
• Kamerasysteme zu aktivieren
Der Radius ist damit das Fundament des gesamten Interaktions- und Dialogsystems.
⸻
🇬🇧 Interaction Radius System – How it Works
This system detects when the player is close enough to interact with an NPC. It forms the foundation for dialogues, shops, and other interaction mechanics.
🔹 Structure
Each NPC has an Interaction Component that creates an invisible interaction radius around the NPC using a sphere collision. This sphere only reacts to the player.
The radius can be adjusted per NPC directly in the level, allowing larger distances when objects like tables or obstacles are in between.
⸻
🔹 What happens technically?
1. NPC owns an Interaction Component
• On BeginPlay, the component creates a Sphere Collision.
• Its size is defined by the variable InteractionRadius.
2. Player enters the radius
• The sphere triggers a Begin Overlap event.
• The component checks if the overlapping actor implements the interaction interface.
• If true, it calls the interface function PlayerInRange on the player.
• The player sets:
• bCanInteract = true
• CurrentInteractable = this NPC
3. Player leaves the radius
• The sphere triggers an End Overlap event.
• The interface function PlayerOutOfRange is called.
• The player resets:
• bCanInteract = false
• CurrentInteractable = None
⸻
🔹 Why use an Interface?
The interface keeps the system independent of a specific player class. Any controllable character that implements the interface can interact.
This makes the system:
• modular
• reusable
• multiplayer-ready
⸻
🔹 Result
When the player enters an NPC’s interaction radius, the player now knows:
“I can interact with this NPC.”
This signal is later used to:
• start dialogues
• open shops
• trigger quests
• activate cinematic camera systems
The interaction radius is therefore the foundation of the entire interaction and dialogue system.