Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.






Tank Physics and Other Progress

Posted by ZBethel, 04 July 2012 · 1,379 views

Tank Game DirectX 11 Bullet Physics
Tank Physics and Other Progress So a lot of life-related stuff happened this Spring--most of it good, but all of it quite mentally taxing. Incidentally, I got sidetracked and took a break from working on my new project. Recently, however, my interest in it is back with a vengence. The truth is I can't stay away from game development for long, it's my life addiction, for better or for worse.

At any rate, I have made a satisfying amount of progress just within the past few weeks. Bullet Physics is now integrated into the engine, and I have made significant improvements to the entity/component system. Right now I basically have a class called EntityFactory that allows you to register new IEntitySpawner derived interface classes, each of which override a single method, SpawnEntity. This will allow me to organize prefabs, since essentially object is a giant bucket of random components. So far, things have been working quite nicely. I have deviated from the Artemis style by allowing my entities to have lists of components, as opposed to a single component of each type. This helps tremendously when your entity is an articulate figure.

Before I say more, check out my first demo video! I'm not sure why the framerate is choppy, it's a smooth 60fps with vsync on my machine.

http://www.youtube.com/watch?v=if5uzJ4dZaA&feature=youtu.be

And if you looking closely, you'll notice that the tank flips over and does some ninja-like action with the turret barrel to pop himself back up. Booya! I plan to render the treads without simulating them, which requires some sort of gear-like rotation constraint between each wheel on a track. Unfortunately, Bullet has no such constraint. Therefore, I will need to write one myself eventually (unless one of you guys have one!). For the moment, I'm using a more involved method of two distance constraints per wheel pair along the track (just the immediate neighbors). They are set 90 degrees apart to avoid the wheels from accidentally switching directions and locking up the treads. It works quite nicely, but it's probably more computation than is necessary. Right now there are 16 distance constraints just to keep the tank wheels in lockstep. I'll need to buff up on my rigid body dynamics before I attempt a better method. If anyone has any suggestions I'd love to hear them.

The tank is basically a bucket of components, that are linked together as they require. For instance, there is basically one transform shared between each rigid body/renderable pair, and each physics constraint require at most two rigid body components. Right now I have three entity systems that are working behind the scenes, one for submitting renderables, one for simulating physics, and one for tank handling. Each system receives an event whenever an entity is created or a component is added. In turn, they keep a local registry of all the entities that they care about (i.e. they have a component that the system is flagged to watch for). The physics system watches out for constraints and rigid bodies. The rendering system watches out for Models (currently the only renderable type). Lastly, the player system watches out for the PlayerController component.

This last component is interesting because it helps turn a pile of intertwined components into a tank. The player controller contains info necessary to drive the tank, not user input. For instance, the tank needs a direction it should head in, a point to aim at, a request to fire, etc. This component is essentially agnostic of whether the user is driving or an AI, which is the point. Moving on, the player system looks for this component, and based on the type of prefab, it can pluck necessary components from the entity to control it. More specifically, the constraint motors are primarily what gives you control over the tank object. Basically, the player system is like a control console for the tank that operates all the machinery in the background.

I haven't figured out the best way yet to feed player input into this system. Most likely the input controller will operate elsewhere in the game object and fire events to this system. An entity could be tagged as the player, and the input applied to the player's tank. The current input scheme is a quick hack to get the demo up and running.

Finally, the concept art you see on the top left of this post is my first attempt at digital drawing. A coworker was giving away his old professional Wacom tablet, and I claimed it! Although my artistic abilities are somewhat lacking, you can see a rough idea of the feel I'm going for in the game. I don't want to give away too much right now, because it's all still very early in development. I just thought I'd throw that out there as a sort of teaser.




very cool! Is this your c++ implementation of Artemis you talked about a while back or your own device using similar concepts?
Yes, although It's not a strict port anymore. I'm often refactoring things trying to figure out how to make the system work for my specific game idea. For instance, the restriction in Artemis of one component off each type is a pain when you're trying to do articulate figures.
yea, I've encountered similar issues, but i work around them by working on an abstract layer one higher than i wish (i.e., working on sets of objects/data in a component rather than several components). So, like with my game, each NPC contains a knowledges component which contains various sets of knowledge. that way i don't have to have several knowledge components. I find it usually works rather well and for the most part, more efficiently (for now of course Posted Image )
PARTNERS