Project Tracks - movable tank tracks - blender game engine race game

(hubar) #1


This Project started in 2014 from a challenge to myself in doing real-time movable tank tracks in Blender Game Engine.
After accomplishing that goal, my understanding of Blender Game Engine grew along with my curiosity to learn how far I could go with Blender and the Game Engine alone in making a full game, while also learning to code.
New goals were set: learn the Game Engine further, find the limitations and try to overcome them, improve my skill in Blender as a modeler and use Blender as the sole software for all assets, scripts, textures, lights etc.
This is the result so far.

Features:- good vehicle physics

  • easy to adapt a new vehicle model to the physics system
  • ballistic gun shots with auto gun adjustment to the target
  • menu system where you can easily integrate a new vehicle or map
  • fun to drive and adjust parameters like:
  1. engine horsepower
  2. maximum rpm
  3. auto shift gear up and down rpm
  4. gear ratios
  5. vehicle weight (mass)
  6. drag and down-force
  7. rolling resistance
  8. suspensions and much more

although you can individually adjust most of the parameters yourself, the system can also automatically adjust engine and suspensions giving just 3 or 4 parameters like horsepower, mass and drag coefficient

What's next? Some ideas still need to be polished but my goal is to develop something between a multiplayer tank game to a tank race game or both.- more vehicles and maps - better overall special effects and graphics
  • optimizations (although this runs on a 2010 laptop with a modest Nvidia GT 425m at 60 to 90 fps, a lot can be done to improve
  • implement an online multiplayer system (big task - need support)
  • create an add-on for Blender to help customize a vehicle
  • release a public demo
  • ultimately try to improve Blender game engine itself (huge task - need a lot of support)

Most used resources:
tutorialsforblender3d.com
blenderartists.org
blender.org/manual/game_engine/index.html
blender.stackexchange.com/

Project Tracks Home page http://hugobarreira.weebly.com/projecttracks

At this stage of development feedback will be important and most welcome

0 Likes

(1000h) #2

I am very fond of the environments shown. Would be very interested in seeing some images. This will also be a very fun tool for experimenting with vehicle physics and hopefully getting some wild results

0 Likes

(hubar) #3

Thanks 1000h,

I intend to make some updates to this thread regularly so you may want to subscribe to it. :slight_smile:

For today, I leave 2 images showing the evolution of the tank models and some work in progress.


The 1st model was actually a slate box with some spheres as wheels but these are just some of the tanks I worked on since I put some tracks finally working and the last one was the race tank Left Bottom corner.
The physics on these tanks use a mass of 5 tons and an engine ranging from 150 to 400 horsepower, top rpm from 2000 to 6000 and and gearbox of 5 or 8 gears giving a top speed of around 74 to 164 Km/h


Based on the last model of the Light tank, I’m now working on some bigger tanks so these models are WIP but they already have physics and work well on the maps. With mass of 5, 36, 60 and 100 tons and engines of 150, 700 and 1500 horsepower I’m testing different variations of the engine and gearbox. The idea is to have an unified system of engine, gearbox, suspension that adapts to the specifications given like mass, horsepower, number of gears and engine type.

I’ll make a video next time exposing this variables and showing the differences.

0 Likes

(Smoliterno) #4

This is awsome! Great work! hope seeing more development posts!

0 Likes

(Nemescraft) #5

How did you make the suspension? Rigid body joints? I am actually trying to accomplish this but I haven’t managed to do it.

0 Likes

(hubar) #6

Hi Nemescraft,
I’ve tried several methods to create a vehicle suspension from rigid body joints, constraint actuators, forces with logic brick or python and probably a lot more just to get to a conclusion that what works best is using either the vehicle wrapper or a similar method with python using raycast.

But all depends how you want your vehicle physics to look like. So too help you with some shortcuts here are some resources you can look at:

  • for rigid body constraints check this

pros: easiest way and you don’t need python or almost none

cons: the down side of using rigid body constraints is that “they are rigid bodies”, not soft bodies, so you can’t really control the wheels at high speeds as they become unstable and too bouncy, also the constraints are very dependent on the mass of the rigid bodies you are applying them, creating a very unpredictable behavior.

  • for vehicle wrapper check this tutorial (you can go more advanced if you look around in this forum)

pros: the most efficient method I found to use in blender game engine very few cpu usage, decent behavior.

cons: Complex to setup, at the moment you have to use lower than reality mass, usually below 300 or thing can go weird, and the worst for me was that I couldn’t find a way to keep the vehicle still while in a slop if I stop the vehicle, it tend to slide even with brakes on.
Still there are very nice uses for this method like this example.

  • For raycast methods check this

It’s the system I’m using and testing at the moment with a lot of tweaks

pros: it’s very versatile and can give you very nice results

cons: it’s a bit heavy on the cpu and complex

By the way, thanks Raiderium for develop this method, after 3 or 4 years it’s still the most complete system for vehicles and BGE that I know of.

Hope it helps,

Cheers

0 Likes

(Nemescraft) #7

I was thinking of using Raiderium’s vehicle physics, but the download site is down.:frowning: Do the tracks also deform along the wheels too? By the way, good work!

0 Likes

(Nemescraft) #8

I was thinking of using Raiderium’s vehicle physics, but the download site is down.:frowning: Do the tracks also deform along the wheels too? By the way, good work!

0 Likes

(hubar) #9

Didn’t knew it was down, it’s a shame.
yes, the tracks deform, I will try to show it someday in a video.

0 Likes

(Smoking_mirror) #10

I love it, kind of like World of Tanks as a racer.
I’m not sure a real tank would drift that much though. :smiley:

0 Likes

(Nemescraft) #11

by the way tank’s speed limit would be around 70 km/h not 160

0 Likes

(hubar) #12

I was thinking of using Raiderium’s vehicle physics, but the download site is down.

site is up again and raiderium updated the files. Thanks raiderium.

@Smoking_mirror : Thanks, indeed WoT is one of my inspirations, isn’t it so much fun a tank with a nice drift :slight_smile:

No really big news just tweaks here and there and a rewriting of the engine and gearbox code. Still finishing to accept real life engines specs translating it to real vehicles results more accurately.

Till then, here is some more pictures:

The flexible tracks



0 Likes

(hubar) #13

Interface studies of vehicles and maps selection (inspired by World of Tanks)




0 Likes

(hubar) #14

another map still WIP, testing texture splatting and shaders in place of a big texture for the terrain.


0 Likes

(lust4blender) #15

the one thing missing from this thread is HOW YOU MANAGED TO GET THE TRACKS TO DEFORM WITH THE WHEELS!

i mean there is no tutorial anywhere online on how to do this right in the bge.

yet here you are with a working prototype that basically showcases battlefield tank physics yet you do no explaining.

are the tracks programmed with python?

are they rigid bodies?

you’re using the ray cast vehicle system, but you have multiple wheels and they all deform the tracks.

PLEASE DO A TUTORIAL ON HOW THIS WAS ACHIEVED.

0 Likes

(haidme) #16

Looking great, keep it up!

0 Likes

(hubar) #17

Hi lust4blender,

  • The wheels and the tracks are ‘no collision’ type, the wheels use a raycast to detect objects and position them
  • The way the tracks deform with the wheels is by ‘pinning’ only some vertices of the track to each wheel so they move up and down with the wheel
  • The method I use to ‘pin’ the vertices to the whels is in blender documentation https://docs.blender.org/api/blender_python_api_2_78_1/bge.types.KX_MeshProxy.html

Basically, the way you grab the vertices to pin to another object is to add a material to a face with the vertices you want to move and check for other vertices in the mesh that have the same position as those vertices.
Then, create a list with those vertices and you can now iterate on that list to, for example, move the vertices.

The way you will then move the vertices is up to you, in my case I use the wheels object to get the appropriate material with the vertices I want in the track object and move them along.

Here is a small tutorial with the method I used to move the vertices.

Hope it’s helpfull,
Cheers

Attachments

moving vertices example.blend (609 KB)

0 Likes

(lust4blender) #18

that’s an awesome way of doing things, but this does not fully explain how you did the tracks XD

i cannot for the life of me figure out how to use this blend to replicate the outcome you have because it still is not fully obvious in your explanation.

yes i know you are using ray cast for the wheels, idk how to program more than four.

yes i do know you are just moving the verts of the track mesh and doing so along on a material but i still have no clue as to how you have it deforming a full track.

0 Likes

(hubar) #19

yes i know you are using ray cast for the wheels, idk how to program more than four.

check the link for raycast method on post 6. Raiderium is the author of that method, it’s very complex, I can’t explain it fully here, from raiderium files you can figure out how to do more than 4 wheels.

yes i do know you are just moving the verts of the track mesh and doing so along on a material but i still have no clue as to how you have it deforming a full track.

The way I’m moving the tracks is using the method in the blend file I send with the example, the verts just move up and down along with the wheel , they do not scroll around. For that i’m using a UVscroller.
This is a good tread to check for uvscroller:


smoking_mirror has a post with the code for the uvscroller in there.

So the tracks moving and deforming is a combination of both methods:

  • the vertices moving up and down method in the file I sent, imagine the bigger red object being the bottom part of the track and 2 wheels going up pulling the verts

  • the tracks moving around using the uvscroller giving the effect that it’s moving but it’s not

  • the track is parented to the tank base and move with the tank base the deformation is done using the pin verts method described.

When I have more time I’ll do a proper tutorial with a video, but 1st I want to make a working demo of the project.
Until then, I hope this at least gives you some clues on how to do it.

0 Likes

(lust4blender) #20

okay i got most of that, but still not understanding how to make the link between the wheels themselves and the track with the whole vert pins.

i mean the blend you uploaded was just a button making them rise which can be changed on each axis, but the tracks are obviously dependent on the wheels themselves which is what i am trying to figure out.

0 Likes