Method GoTo
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
GoTo(Vector3, float)
Moves the hero to a specific position in the world.
public static GoToResult GoTo(Vector3 position, float howNear = 2)
Parameters
position
Vector3The target position to move to
howNear
floatHow close the hero needs to get to the position. Default is 2 units.
Returns
- GoToResult
Reached if the hero reached the position, NotReached if still moving toward it, Unreachable if the position cannot be reached
Remarks
The hero will attempt to find a path to the target position using Unity's navigation system. The method considers a position "reached" when the hero is within howNear units of it.
var result = Hero.GoTo(this.transform.position + new Vector3(10, 0, 10)); // Move 10 units forward and right
if (result == GoToResult.Unreachable)
{
Hero.Say("I can't get there!");
}
// Stay 5 units away from target Hero.position
if (Hero.GoTo(dangerousPosition, howNear: 5) == GoToResult.Reached)
{
Hero.Say("Close enough to the danger!");
}