Construction controls (again), and props

Selection points

Over the last few weeks I’ve been working on fixing something with the construction controls that’s been bugging me for ages.  I wasn’t happy with the range of positions at which you could select a part, you could select it anywhere within its bounds, which wasn’t really restrictive enough.

Here’s an example.  You could select anywhere on a wheel, even though it only has one point that can attach to anything.


Much better to restrict the selection point to always be at this attachment point as shown below, that way it feels more natural when attaching the wheel to another part.


This next example is even worse.  You could select anywhere on a seat, and then translate it so that the selection point was completely outside the seat which is just plain stupid.


So now I restrict the selection point to be somewhere in the region on the bottom of the seat where its attachment points are, so you always have it selected in a suitable place ready to attach to another part.


To accomplish this I had to rework some code so that it now automatically calculates the selection region based on where all the part’s attachment points are located.  The upside to this was that I could do away with explicitly specifying the allowed translation directions on each part.  The less I have to manually setup per part the better!

I also had to implement some new math functions to find the closest point on the part’s selection region to the player’s eye “ray”.  Took a while to do, but it’s never a bad thing to add more stuff to my math toolkit I suppose, could come in handy for other things in the future.

All this took way longer than I expected, it was only supposed to be a couple of day’s work, sigh.

Prop parts

I’ve also added some new “prop” parts.  Props are a new category of part that are the simplest objects in the game, they don’t have a behaviour and they don’t attach to any other part.  The idea is that they can be used with the machines and vehicles you build or placed in the world to set up a scene to play in.  For example, traffic barriers could be laid out to form a race track, the ball could be used in a Rube Goldberg machine.


As with all the other parts, I’ll be adding more props as I go, any suggestions for these are welcome!