Untitled
void runLikeACoward(){ agent.speed = originalSpeed * 2.5f; NavMeshHit hit; bool invalidLocation=true; while(invalidLocation){ Vector3 randomDirection = new Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10)); desiredLocation = transform.position + randomDirection.normalized * 10; if(!NavMesh.SamplePosition(desiredLocation, out hit, 0.1f, NavMesh.AllAreas)) invalidLocation=true; } if(isCowarding) Invoke(nameof(runLikeACoward), 2); else agent.speed = originalSpeed; }