Making a gameObject face at another gameObject?

So I am currently working on a 2D game, and trying to make an enemy that shoots bullets. These bullets are supposed to point at the players position, and then go to that position (not follow the player, just go to whatever the players position was when they are instantiated). However, I can’t seem it get it to work: the bullet always rotates by -90 degrees on the x axis, and because I am making a 2D game, that causes the bullet to disappear from view. Does anyone have any idea of how to do this, or do it in a more efficient way? I have tried to use transform.LookAt and Quaternion.LookRotation.

Thank you!

Edit: Here is my code, except for the part where the bullet damages the player cause that works fine:
Note: My code is quite messy because I have been trying a lot of different things, and I want to remember all of them, so I am keeping it like this just in case if I want to try something out again.

public class BossWeaponController : MonoBehaviour{

``````public GameObject Player;
Transform playerTransform;
Transform target;
Vector3 xAxisDirection;
Vector3 yAxisDirection;
Rigidbody2D myRB;
public float bossBulletSpeed;
public float damage;

void Start()
{
Player.transform.right = xAxisDirection;
Player.transform.up = yAxisDirection;
Transform playerTransform = Player.GetComponent<Transform>();
Rigidbody2D myRB = GetComponent<Rigidbody2D>();
// target = new Vector3(Vector3.forward, yAxisDirection);
// transform.Rotate(Vector3.forward * -90);
target = Player.transform;
//This is where I change the rotation
Vector3 relavtivePos = playerTransform.position;

// Quaternion rotation = Quaternion.LookRotation(Vector3.forward,relavtivePos);
transform.LookAt(target, Vector3.up);
// transform.rotation = rotation;

}

// Update is called once per frame
void Update()
{
transform.position = Vector2.MoveTowards(transform.position, target.position, bossBulletSpeed);
}
``````

That’s because you’re using 2d vectors for caclulating Quaternion. Use Vector3 or use different method for calculating rotation

As for LookRotation, if you have 2D set in XY plane, then your up vector would be on Z axis (Vector3.forward)

Have you tried ` Vector2.MoveTowards()`? Vector2.MoveTowards Documentation

Moves a point current towards target.

When the bullets are instantiated, you would need to create a new Vector2 that contains the current player position and set that as the target. This will mean that the variable will not update accordingly to the player’s moving position, and it will go in a fixed trajectory.
@BlueFFlame