Method FindNearestInteractive
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
FindNearestInteractive(string, string, string, float)
Finds the nearest interactive object (like chests or shrines) that matches the name criteria.
public InteractiveBehaviour FindNearestInteractive(string name1 = "", string name2 = null, string name3 = null, float maxDistance = 15)
Parameters
name1
stringPrimary name to search for. Object name must contain this string. If empty, matches any name.
name2
stringOptional secondary name to search for. If provided, object name must contain either this or name1.
name3
stringOptional tertiary name to search for. If provided, object name must contain either this, name2, or name1.
maxDistance
floatMaximum search distance from the hero. Defaults to 15 units.
Returns
- InteractiveBehaviour
The nearest InteractiveBehaviour that matches the criteria, or null if no matching object is found.
Remarks
This method searches for objects on the Interactable layer, which includes:
- Chests containing loot
- Shrines providing buffs
- NPCs for trading and dialogue
var chest = FindNearestInteractive("Chest");
if (chest != null)
{
if (InteractWith(chest))
{
Say("Found and opened a chest!");
}
}
var shrine = FindNearestInteractive("Shrine");
if (shrine != null)
{
InteractWith(shrine);
Say($"Used {shrine.name}!");
}
FindNearestInteractive(Predicate<InteractiveBehaviour>, float)
public InteractiveBehaviour FindNearestInteractive(Predicate<InteractiveBehaviour> predicate, float maxDistance = 15)
Parameters
predicate
Predicate<InteractiveBehaviour>maxDistance
float