- Home /
Question by
raca0208 · Jun 26, 2020 at 07:44 PM ·
unity 2dprojectilecollision2dprojectiles
How do I make a projectile go in a straight line after colliding with another projectile?
I'm making a game where there are different types of projectiles and there's an especific case where I wish that one projectile keeps moving foward while the other dissapears. But, when the two collide, the first projectile sometimes goes to another direction, which is not something I want, since I want the projectile to keep the same direction as before colliding with the other projectile. I tried freezing the positions of the projectile prefab, but that didn't work. Any ideas?
Here's the code when the projectile is fired, taken from here
void Shoot(){
GameObject bullet = Instantiate(bulletPrefab[GlobalVariables.weaponType], firePoint.position, firePoint.rotation);
Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();
rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
}
Comment