thombruce / verse

🚀 A universe in progress
Other
8 stars 0 forks source link

Beam weapon #69

Open thombruce opened 12 months ago

thombruce commented 12 months ago

A beam weapon. This should not spawn a tangible/consistent entity like the ballistic cannon, but should instead draw a beam in the pointing direction of "infinite" length. If the beam intersects with a ship or other collidable object, the length should be the distance between the emitter and the hit entity.

The beam should travel at the speed of light (though this is not worth considering at the scales we're playing at, I don't think), meaning that if relevant the length of the beam ought to grow the longer it is being fired... and when released, that length should persist as it fades into the distance. Again, not worth considering at the current scale - we'll skip this for now, I think.

I know roughly the logic that goes into producing a beam...

  1. If a ship is firing its beam weapon...
  2. Calculate a line of "infinite" distance from the ship in the direction it is facing
  3. If this line intersects with some other entity, restrain the length to this distance (closest intersection)
  4. Draw that in the scene and emit the consequences to the event system (probably)

It's the drawing part I'm unsure of. I'm sure I can draw a simple line in Bevy, I just haven't worked with Bevy's geometry components yet. I'm also not sure if it is the correct approach, or if a texture ought to be used instead. Any texture used would need to be repeating for the full length of the beam... And one thing I would like is for the beam to grow weaker over a greater distance (an imperfect laser), but again, this is unlikely to be relevant at the current scale.

What IS relevant at the current scale is this: The player should not be able to use this at infinite distances regardless of my talk of "infinite" length above. The player should not be able to sweep an arc around the scene and connect with enemy entities 10s of thousands of metres away.


Eventually beam weapons should maybe be affected by large gravitational objects like black holes (I've recently been playing with applying gravity to the ballistic weapons, but have not yet committed to implementing this).

This may inform the decision about whether or not to draw a geometric line or a texture-based one. A texture would be harder to bend, and you'd see the breaks in the texture as you attempted to do so, no? Hence I think drawing it as a textureless entity, based only on Bevy's geometry and drawing capabilities is the right way to go.