Enemy Wont Shoot At Player

I am trying to get the enemy to shoot out a magic bolt to the enemy I have everything else down except this the bolt just either shoots up down or toward the enemy please help (I am working in a 3D space)

heres the code:

rb = GetComponent();
player = GameObject.FindGameObjectWithTag(“Player”);

    Vector3 direction = player.transform.position - transform.position;
    rb.velocity = new Vector2(direction.x, direction.y).normalized * BulletForce;

Is your enemy already facing the player? If so, you could just try using the enemy’s transform.forward for a direction

Thank you but I dont know how to make it so it still moves forward with enemy.transform.forward

set the bolt the same rotation as the enemy (a bit hacky, but if your enemy is facing the player then it should work), then the forward of the projectile will be facing the player, so just move it, well, forward.
(forward is just a direction so you can use it for rb.velocity* BulletForce)

thank you it is shooting at the player now but the bolt only chooses one enemys rotation and the other just shoots itself could you please help heres the updates code

enemy = GameObject.FindGameObjectWithTag(“Enemy”);

    gameObject.transform.rotation = enemy.transform.rotation;

    rb.velocity = gameObject.transform.forward * magicSpeed;