Question by
abishekpoudel2014 · Mar 30, 2019 at 01:35 AM ·
aienemy
So i am making an enemy that goes towards player's initial direction but player can move away from that direction
float speed = 3f;//speed of object
GameObject player; //Reference of player
// float waitTime;//Time to wait // public float startWaitTime; Vector2 playerPos;//To know position of player
private void Start()
{
player = GameObject.FindWithTag("Player");
playerPos = new Vector2(player.transform.position.x,player.transform.position.y);
Debug.Log("Took pose");
}
private void FixedUpdate()
{
transform.Translate(playerPos * speed * Time.deltaTime);
Debug.Log("Moving towaeds player");
}
Comment