Hello,
I’m using the new 2D tools and trying to make it so I shoot a bullet in the direction of my mouse pointer. The only problem is the BoxCollider2D on the bullet does not match the angle it is travelling. Here is what I am seeing
![1]
From what I can tell this is being caused by the X and Y rotation changing from the way I instantiate the bullet (only the Z rotation is important for 2D correct?) Here is the code that I am using to rotate the game object from which I instantiate the bullets
Vector3 upAxis = new Vector3(0,0,1);
Vector3 mouseScreenPosition = Input.mousePosition;
mouseScreenPosition.z = transform.position.z;
Vector3 mouseWorldSpace = Camera.mainCamera.ScreenToWorldPoint(mouseScreenPosition);
bulletSpawn.transform.LookAt(mouseWorldSpace, upAxis);
And here is the instantiation code
if (Input.GetButton("Fire1") && Time.time > nextFireTime)
{
nextFireTime = Time.time + fireRate;
Instantiate(bullet, bulletSpawn.position, bulletSpawn.rotation);
}