Triggerless Section Drone Tutorial

Got questions about Shipmaker? Get answers here. Please read the stickied topics first!

Moderators: th15, Moderators

Post Reply
STARSTRUCK
Moderator
Posts: 342
Joined: Wed Mar 03, 2010 3:46 pm
Location: sent milady ;)

Triggerless Section Drone Tutorial

Post by STARSTRUCK »

"Triggerless" Section Drone
This style of section drone uses no triggers and only two driver turrets. It's a lot simpler than Zalausai's version, but tends to randomly "jump" due to the way turrets track. It also undocks from and returns to the ship reliably, although it may "jump" and return from the opposite direction.

The geometric idea behind this method is that a circular arc subtending a small enough angle will roughly approximate a straight line. In this case, the arc is the traversal of a very large turret, and the straight line is between your ship and its target.

Image

First, you'll need to arrange something like this. Here, we've four sections and two dummy weapons, coded according to color. The yellow section is parented to the green section, the green section to the red section, and so on.

For simplicity, let's give our drone a range of 1,000 px and use an arc with a radius of 9,999 px, the largest position value we can set in SM. I'll use 10,000 in calculations.

Set the range of the blue weapon to 1,000 and have it drive the blue section. Set its arc range to 180° so it can face in any direction. This turret will control the direction in which the drone travels.

As for the green turret, we first need to calculate the arc range we want to set. Find tan-1(range/radius). tan-1(1,000/10,000) is about 5.7°, so we'll set the arc range to that. Give it a range of twice our arc radius, or 20,000. Set the Turning to something small, like 0.1°.

Why so small? A Turning of 0.1° means the turret moves 0.1° per frame, or (0.1/360)*2π(10,000) = 17.5 px along the arc. This is already slightly faster than a blaster shot.

Accordingly, let's assume an engagement distance of 1,000. Multiply the previous angle by 10, and you get 1.0°. Set this as the turning for the blue turret, so that (at maximum range, at least) the drone moves sideways just as fast as it moves forwards.

Now that we're done statting everything, let's put all the sections and weapons where they belong. If you want, you can give everything an empty sprite beforehand. Put the blue and yellow sections at the turret center, i.e. (0,0). Put the red and green sections and weapons at (0,9999).

The yellow section tracks the target with surprising accuracy (enough to park inside of Enemy 10). You'll want to put your weapons/whatever on there.

You may also have noticed that the Size of this ship is ridiculous. If you want to keep the threat circle small, you'll need to enable movement and set a trigger that disables it after the sections move into their positions one frame later.

Image
How it should look

Attached is a functional example. You probably won't need an exploded version, since the thing is simple enough in principle.
Attachments
SS Drone B.sb4
(1.99 KiB) Downloaded 1035 times
SS Drone B.shp
(1.95 KiB) Downloaded 1086 times
Post Reply