Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

Author Topic: Engine trails Flare based on direction of movement  (Read 2116 times)

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Engine trails Flare based on direction of movement
« on: November 04, 2019, 01:09:02 PM »

I have a ship with engines both front and back, and thus noticed that when going forward, all engines Flare, even those that logically shouldn't. Likewise, when going backwards all engines are dimmed.

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #1 on: November 06, 2019, 02:36:45 AM »

Starsector never implemented a simple engine angle check.

It really shouldn't be that hard to have the game check engine angles and treat all pointing back/forward as main engines/retros and the rest as manouvering thrusters and fire them accordingly.


Basically, since 0° is forward, anything from 315° - 45° would be retro thrusters, from 45° - 135° right manouvering, from 135° - 225° main thrusters, from 225° - 315° left manouvering.

If strafing right, fire all right ones.

For turning the ship an additional check is needed - offset from center.
So, if you're turning right, fire all RIGHT trusters that have positive ++ offset ( coordinates 20.5 and 50.8 would mean thruster is located forward right on the ship) AND all LEFT thrusters that have negative -- offset.

For turning left, you'd check the same, but offsets would be -+ for right and +- for left.

Simple to implement, but we're talking a minimal 6 new engine points per ships. I don't know how it would affect performance, but shouldn't be too bad.
« Last Edit: November 06, 2019, 03:00:16 AM by TrashMan »
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #2 on: November 06, 2019, 06:25:21 AM »

It's a bit more complicated than that since you can combine two translate directions and rotations, but there is a simple script available in MagicLib that allows you to do just that using simple deco weapons.
Logged
 

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #3 on: November 07, 2019, 02:39:13 AM »

It's a bit more complicated than that since you can combine two translate directions and rotations, but there is a simple script available in MagicLib that allows you to do just that using simple deco weapons.

Deco weapons are a bad solution. Engine code is far more efficient and simple.
And insofar as more complex - not by much, since you simply fire all aplicable thrusters depending on movement.
Non-nested if statements basically.
Code
IF moving forward - forward thruster fire code
IF moving backward - backwards thrusters code
IF strafing left - left strafe code
IF strafing right - right strafe code
IF turning right - right turn code
IF turning left - left turn code

Backwards + left strafe + left turn would simply execute all aplicable codes and fire all aplicable thrusters.
There might be a more efficient way to go about it (without changes in the ship files structure)
At the end of the day you want as few checks as possible
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #4 on: November 07, 2019, 02:51:25 AM »

Errr no, using deco weapons is an order of magnitude faster than the vanilla engines, and it is slightly simpler on the code side since you have full control over those, unlike the vanilla engines.

Additionally non nested IFs can result in undesirable effects such as opposing thrusters firing up at the same time, cancelling eachother when for example you straffe right while turning to the right at the same time.
Logged
 

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #5 on: November 07, 2019, 03:10:08 AM »

Why would they be canceling each-other? Thrusters are either on or off. If you strafe right and turn right, assuming a sensible thruster setup, the thrusters that would fire would be left thrusters (to move right) and bottom right one (right rotation is bottom right and top left, which is already fired from moving right)


But I do have to look into the deco weapons. Don't they take up a weapon group slot? That is a BIG downside.
Logged

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #6 on: November 07, 2019, 04:01:49 AM »

The thrusters firing would be all the left ones to straffe right, and the bottom right one to turn right (the top left one being already on), meaning that both the bottom left and bottom right thrusters are working against eachother. It would make more sense to have only top left thrusters firing, otherwise you are just wasting thrust.

And if you want to have separate mid-ship thrusters for translation and corner thrusters for rotation, then you are not using the full available thrust to maneuver which makes even less sense.
Logged
 

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #7 on: November 07, 2019, 12:20:21 PM »

Which still wouldn't be a problem if it was dependent on relative angle to the wanted direction of travel.
(Besides which, it can just be cosmetic.)
Wouldn't decorative weapons... not function as engines?

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #8 on: November 08, 2019, 12:40:08 AM »

Vanilla engines are but a special kind of decorative weapons themselves. They do not provide "thrust". The script in MagicLib detects flameouts though, and can tie the deco to an invisible engine emplacement if that is desired.
« Last Edit: November 08, 2019, 12:44:15 AM by Tartiflette »
Logged
 

TrashMan

  • Admiral
  • *****
  • Posts: 1325
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #9 on: November 08, 2019, 02:39:30 AM »

The thrusters firing would be all the left ones to straffe right, and the bottom right one to turn right (the top left one being already on), meaning that both the bottom left and bottom right thrusters are working against eachother. It would make more sense to have only top left thrusters firing, otherwise you are just wasting thrust.

And if you want to have separate mid-ship thrusters for translation and corner thrusters for rotation, then you are not using the full available thrust to maneuver which makes even less sense.

That could be easily solved - a thruster is only on if it recieves no conflicting inputs (input 1 and 1, 0 and 0 and it's off. 1 nad 0, or 0 and 1, and it's on)
Logged

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #10 on: November 08, 2019, 02:53:04 AM »

Vanilla engines are but a special kind of decorative weapons themselves. They do not provide "thrust".
And yet losing them affects your max speed.

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #11 on: November 08, 2019, 03:50:30 AM »

And yet losing them affects your max speed.
The engine themselves do not control the behavior of the ship: you can go backward despite not having any engine to the front, you can make engine-less ships... What I'm trying to explain is that this isn't KSP, the engines aren't providing "thurst" as in applying a force to the ship object. It's all abstracted! That's why making maneuver thrusters is mostly visual flair without any ties to the mechanics of the game:

« Last Edit: November 08, 2019, 03:54:51 AM by Tartiflette »
Logged
 

Yunru

  • Admiral
  • *****
  • Posts: 1560
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #12 on: November 08, 2019, 05:23:54 AM »

And yet losing them affects your max speed.
The engine themselves do not control the behavior of the ship: you can go backward despite not having any engine to the front, you can make engine-less ships... What I'm trying to explain is that this isn't KSP, the engines aren't providing "thurst" as in applying a force to the ship object. It's all abstracted! That's why making maneuver thrusters is mostly visual flair without any ties to the mechanics of the game:


And what I'm saying is if you take a missile to one of those engines your top speed drops.
Which, correct me if I'm wrong, wouldn't happen with a strictly decorative weapon?

I'd also note that if the left half get disabled, going forwards causes a ship to spin, so it's clearly more than just visuals.

Tartiflette

  • Admiral
  • *****
  • Posts: 3529
  • MagicLab discord: https://discord.gg/EVQZaD3naU
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #13 on: November 08, 2019, 05:25:39 AM »

As I said earlier:
The script in MagicLib detects flameouts though, and can tie the deco to an invisible engine emplacement if that is desired.
So yes it does if you set it up for that.
Logged
 

bobucles

  • Admiral
  • *****
  • Posts: 532
    • View Profile
Re: Engine trails Flare based on direction of movement
« Reply #14 on: November 08, 2019, 05:45:23 AM »

Quote
And what I'm saying is if you take a missile to one of those engines your top speed drops.
Does maneuverability get affected as well? It might be fun to put extra targets on ships. Although a ship already loses both speed and maneuvers when they flame out, more targets definitely means more problems for sure.