Page 7 of 7

Re: Desert Space - Jump Motherfucker

Posted: Sat Nov 02, 2019 11:53 pm
by Awaketo


PresentaciĆ³n final del juego Desert Space.

https://github.com/EliteV1/Desert-Space-Codigos

Repositorio Juego Desert Space.

Re: Desert Space - Jump Motherfucker

Posted: Fri Nov 15, 2019 3:48 pm
by MateoLC

Code: Select all

public class Enemy : MonoBehaviour
{

    public float visionRadius;
    public float spppeed;

    GameObject player;

    Vector3 initialPosition;
    // Start is called before the first frame update
    void Start()
    {
        player = GameObject.FindGameObjectWithTag("Player");
        initialPosition = transform.position;
    }

    // Update is called once per frame
    void Update()
    {
        Vector3 target = initialPosition;

        float dist = Vector2.Distance(player.transform.position, transform.position);
        if (dist < visionRadius) target = player.transform.position;

        float fixedSpeed = spppeed * Time.deltaTime;
        transform.position = Vector3.MoveTowards(transform.position, target, fixedSpeed);

        Debug.DrawLine(transform.position, target, Color.green);
    }
    
}