Closed thombruce closed 12 months ago
The way that we detect collisions right now is to detect events matching CollisionEvent::Started
from the Rapier2d physics system.
But we can also check CollisionEvent::Stopped
to determine when the bullet has left the spawner's collider.
At this point we would either...
Why some combo? Because it might be useful to keep the spawner detail around on the bullet, so that we know whose bullet hit what. This will be useful for determining whether or not to award points to the player (and while multiplayer is not planned, it would be crucial to know who destroyed who in a multiplayer setting).
So consider adding a Spawner or SpawnedBy entity component to the projectiles, and flagging the bullet as at least InertToSelf (maybe InertToAll) until the initial CollisionEvent has stopped.
Ship is occasionally hit by own bullets when ship speed is in excess of 500 m/s.
This is partially a system ordering issue: Ship movement and bullet spawning/movement are not ordered in a way which prevents this happening.
But this is why I've previously spawned bullets out in front of the ship X amount of metres too; it was a sloppy workaround to prevent collisions with self. We might consider going to the root of the problem instead... Ideally we want to introduce a rotating turret-mounted gun at some point, and the bullets from this would spawn within the collider of the player/enemy ships, so we need to resolve the problem eventually.
Suggested solutions:
Reasons not to like:
So how would a combo work? We spawn a bullet with knowledge of its spawner, preventing it from hitting the spawner at the time it was spawned. Then, after a few hundred milliseconds, we remove that knowledge thus enabling friendly-fire and damage to self under the effects of gravity, etc.
Is this the best way to achieve this?
Is this the only way to achieve this?
Let's restate the problem:
I can't think of a better way about it than... yeah, the bullet needs to know who fired it initially.
But be wary of the concept of larger and larger ships. Eventually (maybe right now) we want to be able to mount weapons systems at different positions on the ship. For very large ships, this might mean turret-mounted guns the projectiles of which would need to traverse the breadth or length of the ship before leaving its collider...
...which means the easiest thing to do is to ignore the spawning entity entirely, rather than ignore it for a given length of time.
Can we... make the bullet "ACTIVE" after leaving the collider it was initially spawned in?
I mean, I'm just thinking about a possible setup later in development, where the player might set up two wormholes and fire bullets at themselves through them - they'd expect to hit themselves. We need friendly fire to be on by default. We just need to ignore the overlap initially.