So I have a enemy in my scene and everything works, I just cant get it to aim at my player.
The Snowballs are launched out of the launchPoint but I cant figure out how to rotate it to aim directly at the player.
Here’s the code that makes him fire:
void Fire()
{
if (!alreadyAttacked)
{
GameObject projectile = Instantiate(Snowball, launchPoint.position, launchPoint.rotation);
Rigidbody rb = projectile.GetComponent<Rigidbody>();
rb.AddForce(transform.forward * XForce, ForceMode.Impulse);
rb.AddForce(transform.up * YForce, ForceMode.Impulse);
alreadyAttacked = true;
Invoke(nameof(ResetAttack), throwCoolDown);
Destroy(projectile, 10);
}
}
He shoots in the general direction of the player, but doesn’t hit him.