I'm creating a simple Bullet Hell game and I'm testing some things out. I want the enemy bullets to shoot towards the player as soon as he fires.
I tried a bunch of Quaternion methods including LookTowards, FromToRotation, AngleAxis, (etc...) and none seemed to work.
void Start () {
...
StartCoroutine("Shooting");
}
IEnumerator Shooting()
{
while(dead != true)
{
Vector3 position = new Vector3(rb.position.x, rb.position.y - 5f, 0);
Instantiate(Ebullet, position, Quaternion.Euler(0, 0, player.transform.position.x));
yield return new WaitForSeconds(t);
}
}
I expected the bullets to move directly to the player's last known position, instead the enemy shoots at a wrong angle and everytime the player moves, the angle changes according to the the player's left or right movement.