Stormworks: Build and Rescue

Stormworks: Build and Rescue

Not enough ratings
Rangefinder Adjusted Gun Elevation
By 866
This is a tutorial/function for gun elevation adjustment based on the rangefinder.
4
   
Award
Favorite
Favorited
Unfavorite
Showcase
Un-ranged vs. Ranged:


About Drag Coefficient
I have not incorporated shell drag coefficient into this function as I don't know how yet, however the shell velocity drop in Stormworks is very low and the error is mostly negligible.

I do plan on adding drag calculation for this in the near future once I have figured it out.
Example
Here is an example function implemented on a battle cannon on a turret:
Sight & Rangefinder: Fixed on the turret, pivoting using internal pivot
Gun elevation: Input from robotic pivot
Tilt Sensor: For measuring turret tilt (not battle cannon)


Function:
atan((30*(x/800)^2/2)/(cos((y-z)*pi/180)*x))*180/pi

**Output is in degrees**

x= range in meters
y= gun elevation(relative to the turret) in degrees
z= turret elevation(relative to horizon) in degrees

Explanation:
  • pi/180 and 180/pi:
    for converting degrees into radians and vice versa. (Stormworks trigonometry functions use Radians)
  • x/800:
    the battle cannon shell travel time, 800 being the battle cannon shell's speed in m/s.
  • 30:
    the shell drop due to gravity in m/s^2. (Stormworks devs decided it's 30 so it's 30)
  • 30*(x/800)^2/2:
    shell drop vertical distance based on the shell travel time.
  • y-z:
    the current gun elevation relative to horizon (It can be replaced with one single variable with a tilt sensor on the gun)
  • cos((y-z)*pi/180)*x:
    the horizontal distance between the rangefinder and the target.
  • atan((30*(x/800)^2/2)/(cos((y-z)*pi/180)*x)):
    using the calculated horizontal distance and the shell drop vertical distance to calculate the required gun elevation adjustment.

I recommend using separate pivot for gun sight and rangefinder vs. the cannon, reason being you can keep your sight and rangefinder on target.

The parameters for various weapons are provided in the official Stormworks Discord Channel.
End
Feel free to implement this into your creations, credits would be appreciated.

If anyone knows how the drag coefficient works please let me know so I can improve my design.
3 Comments
未完童话 12 Jul @ 12:27pm 
gravity is 50 now:steamhappy:
Круто всі заїбісь
paulwigfield 31 May @ 4:21pm 
nice