OC – The “Skateboard”

Where I left off in the last post, I mentioned that I had to use “game logic” to figure out a good way to get the ball wheel design working. Funny thing, I did exactly that. In the real world, we don’t have things that can pass through other objects like a ghost. It might be handy, but that kind of thing isn’t part of our reality.

After pondering the roller/cage problem for a while, I realized — I was thinking in too literal a fashion. I didn’t have to make a containment system like I would if this was a physical object. The solution was to have a support strut that went into the center of the sphere wheel with a ball joint at the end.

The result looked like this:

Why red support struts? Just for visibility so I could see what was going on…

In the background there you can see the blue crane-like rig I used to figure out if the wheels would work at all. It was fun putting it together and making it move around. I call this design the “Skateboard” because there is absolutely no way to directly power the wheels. I was stumped for a bit until a fellow modder Dima helped me out.

The answer? I was trying to apply Body Impulses using the modding API to the frame, but the results were not what I had hoped for. Dima showed me that applying vectors of force to the pivot was the way to go, in addition to using Constraints so the speed didn’t get out of hand.

With that under my belt, I was able to hack something together that not only used a “front drive” but something I like to call “crab drive” — where force is applied to the center of mass so all the wheels turn in the same direction. Think parallel parking and you want to go sideways into a spot. Well if this was on your car, you would have no trouble at all.

Demonstrating front drive mode, then crab mode. Watch the difference in steering.

Not bad, but I’m sure you see the problem in front drive mode — the rear wheels tend to just roll with momentum so sometimes they start to overtake the front and rotate the entire body. That isn’t something I wanted. Crab mode however is rock solid because center of mass is a pretty stable place to apply forces from.

This was my first problem – how to use front drive mode without the back end swishing everywhere? Some might prefer the out-of-control feel of driving that way, but I knew most would be expecting conventional drive, where small adjustments to steering didn’t cause the back end to shimmy all over.

After some research I realized that I needed to apply some counter-force to the rear of where the front drive forces were being applied. In Teardown, the pivot point of the body determines where those forces get placed, unless you calculate the center of mass like I had.

So this meant I needed to figure out how to create a virtual pivot point to apply forces so the tendency to turn/swivel after each forward push was minimized. Let me tell you, that wasn’t too easy. I never had higher math courses and I’ve only recently dove in to Trigonometry, like this diagram below from Gamedev dot tv:

Is your brain melting yet? Oh trust me, it will…

That diagram shows what is needed to solve an arbitrary angle using math for a right triangle. Yep, games have lots of math in them, but its all hidden away in functions and other bits.

I had to figure out somehow this “Virtual Pivot” problem before I could even hope to stabilize the driving behavior of Omnicar.

(To be continued)