I am working on a 2d Game. In my game, ai (doesn’t move) shoots the player. how to get the position to shoot in the player direction
My code doesn’t work accurately
Enemy
void Fire()
{
Instantiate(sawGameObject, transform.position, Quaternion.identity);
}
Bullet
void Awake()
{
target = GameObject.FindGameObjectWithTag(“Player”);
player = FindObjectOfType<PlayerControler>();
direction = (target.transform.position - transform.position).normalized;
}
void Update()
{
Vector3 temp = transform.position;
temp += direction * speed;
transform.Translate(temp * Time.deltaTime);
Destroy(gameObject, 0.6f);
}
HELP PLEASE