Question by
diogoviveiros · May 26, 2020 at 04:14 PM ·
2dinstantiateprefab
Size of instantiated clone is different from prefab
Hello,
I'm trying to create a shooting projectile system where clicking the mouse button instantiates a projectile from a prefab. However, it's not working properly as when I shoot, the clone becomes "squished" in the y axis, as you can see:
The one on top is the clone, and the one on the bottom is the prefab that the clone should look like.
Here is my code, I've tried checking everything but I can't understand why this is happening:
public class Shooting : MonoBehaviour {
public Transform firePoint;
public GameObject bulletPrefab;
public float bulletForce = 20f;
// Update is called once per frame
void Update()
{
if (Input.GetButtonDown("Fire1"))
{
Shoot();
}
}
void Shoot()
{
GameObject projectile = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
Rigidbody2D rb = projectile.GetComponent<Rigidbody2D>();
rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
}
}
Thanks in advance for your help!
capture.jpg
(29.6 kB)
Comment