Game Development Reference
In-Depth Information
void Update()
{
if (TargetLocation != Vector3.zero && TargetLocation !=
transform.position && TargetLocation != StartLocation)
{
transform.position =
Vector3.Lerp(StartLocation,
TargetLocation,
MovementCurve.Evaluate(timer));
timer += Time.deltaTime;
}
if (startedTravelling && Vector3.Distance(StartLocation,
transform.position.ToVector3_2D()) > 0.5)
{
this.collider2D.enabled = true;
startedTravelling = false;
}
//If there is an encounter distance, then a battle must
occur.
//So when the player has travelled far enough,
//stop and enter the battle scene
if (EncounterDistance > 0)
{
if (Vector3.Distance(StartLocation,
transform.position) > EncounterDistance)
{
TargetLocation = Vector3.zero;
NavigationManager.NavigateTo("Battle");
}
}
}
Search WWH ::




Custom Search