Hi guys,
Only really noticed this recently, my player when moving really fast and shoots catches up to his own bullets.
had a dig round but couldnt find a good answer. I tried to add my player rigid body velocity to the bullet speed, but its just not working. here is my bullet code:
public void FireLaser()
{ if (!hyperSpace && isAlive)
{
playerLaser.Play();
GameObject newLaserRed = Instantiate(laserRed, weaponSpawnPoint.transform.position, transform.rotation);
newLaserRed.GetComponent<Rigidbody2D>().AddRelativeForce(Vector2.up * laserRedSpeed);
Destroy(newLaserRed, 0.8F);
}
}
Layers? I thought layers were just for detecting collisions and interaction. I tried moving my bullets to another layer but it didnt work.
Are you concerned with him running past his bullets?
The only solution here is to slow the player down or speed the bullets up, obviously.
I assumed you were concerned that the bullets were hitting him when he caught up to them, in which case layers and the collision matrix is where you fix that.
1 Like
Yes, should have been clearer. No my player isnt hitting his own bullets. When travelling fast the player catches them. I suppose i can make the player shoot a certain speed, but if hes going faster than a certain speed, shoot faster.
Think that through before you waste too much time on it.
-
Player is going 10 m/s, presses FIRE
-
Normal bullets shoots at 20 m/s
-
So you decide “okay this bullet goes at 30 m/s”
Then player accelerates… to 40 m/s or even higher…
And catches up to the bullet.