Esempio n. 1
0
    void SetTargetPositionRandomly()
    {
        bool isReachable = false;

        do
        {
            var heightIndex       = Random.Range(0, gameSpace.heights.Count);
            var direction         = Quaternion.AngleAxis(Random.Range(0f, 360f), Vector3.up) * Vector3.forward;
            var distance          = Random.Range(0f, gameSpace.radius);
            var height            = gameSpace.heights[heightIndex];
            var candidatePosition = direction * distance;
            candidatePosition.y = height;
            isReachable         = _shipMovement.ChangeTargetAgentPosition(candidatePosition);
        }while(!isReachable);
    }