Hello. I am very new to Unity and programming. I am seeking help for a 2D A.I script that allows objects to avoid other objects while advancing to player (kind of like zombie). The code is required for a top down/isometrical game. If you could assist me or if you could direct me to a tutorial relevant to what I am seeking, I would greatly appreciate it. Thanks!
My code looks like this
using UnityEngine;
using System.Collections;
public class AI1 : MonoBehaviour {
private Vector3 Player;
private Vector2 Playerdirection;
private float Xdif;
private float Ydif;
public float speed;
// Update is called once per frame
void Update () {
Player = GameObject.Find("Player").transform.position;
Xdif = Player.x - transform.position.x;
Ydif = Player.y - transform.position.y;
Playerdirection = new Vector2 (Xdif, Ydif);
}
}
It goes for the player but it gets stuck. :(
↧