Поворот спрайта в скрипте

Помогите развернуть объект при ходьбе в этом коде:

public float speed;

public Transform start;
public Transform end;

public float arriveTime = 3f;

public int ControllPosition;
public Transform point;
bool moveinRight;

Transform player;
public float StopingDistance = 10;

bool chill = false;
bool angry = false;
bool goBack = false;


void Start() {
    player = GameObject.FindGameObjectWithTag ("Player").transform;
}

void Update() {
    if (Vector2.Distance(transform.position, point.position) < ControllPosition && angry == false) {
        chill = true;
    }

    if (Vector2.Distance (transform.position, player.position) < StopingDistance) {
        angry = true;
        chill = false;
        goBack = false;
    }

    if (Vector2.Distance (transform.position, player.position) > StopingDistance) {
        goBack = true;
        angry = false;
    }

    if (chill == true) {
        Chill ();
    } else if (angry == true) {
        Angry ();
    } else if (goBack == true) {
        GoBack ();
    }
}


void Chill() {
    transform.position = Vector2.Lerp (start.position, end.position, Mathf.PingPong (Time.time / arriveTime, 1f));
        
}


void Angry() {
    transform.position = Vector3.MoveTowards (transform.position, player.position, speed * Time.deltaTime);
    speed = 3f;
    
}


void GoBack() {
    transform.position = Vector2.MoveTowards (transform.position, point.position, speed * Time.deltaTime);{ 
        speed = 3;
    }
}

вообщем код написан так что при достижении GameObject "1" противник идет к номеру 2, мне нужно чтобы при достижении объекта 1, он поварачивался в право, а при достижении объекта 2, в лево.


Ответы (0 шт):