Can anybody explain how I can instantiate the bullet prefab at the correct rotation? It’s coming out vertically when it’s supposed to be a horizontal sprite.
Here’s my script if necessary
public class Shooting : MonoBehaviour
{
public Transform firePoint;
public GameObject bulletPrefab;
[SerializeField] float bulletForce = 20f;
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
GameObject bullet = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
Rigidbody2D bulletRB = bullet.GetComponent<Rigidbody2D>();
bulletRB.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
GetComponent<AudioSource>().Play();
}
}
