-1
\$\begingroup\$

I have created a character. It is a zombie that I design.

I have this code for the zombie to follow my character controller:

void Update () {
    if (jugador.position.x > transform.position.x)
    {
        transform.position+=new Vector3(velocidad, 0f, 0f);
    }
    if (jugador.position.x < transform.position.x)
    {
        transform.position+=new Vector3(-velocidad, 0f, 0f);
    }
    if (jugador.position.z > transform.position.z)
    {
        transform.position+=new Vector3(0f, 0f, velocidad);
    }
    if (jugador.position.z < transform.position.z)
    {
        transform.position+=new Vector3(0f, 0f, -velocidad);
    }
}

Perfect, the zombie follows my gameobject firsperson controller with the variable jugador. The problem I have is that he follows me backwards and I can not get him moving towards the character.

Do you know how I can rotate the zombie toward the character?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.