Search Unity

Tank Treads - Physic Simulation WIP

Discussion in 'Made With Unity' started by Digital, Mar 19, 2011.

  1. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    This is tank physic simulation. There's no track animation, everything is done with physics. I'm trying to create a realistic tank movement.

    - Controls -
    - W, A, S, D

    - UPDATE 0.3
    - Added breakable tank tracks
    - Added two more wheels
    - Physics tweaking

    - Here is a new preview, you can drive the tank until the tracks break.

    - Web Preview -
    http://dl.dropbox.com/u/20429633/Tank%20Simulation/Tank%20SIM%200.2/WebPlayer.html

    - Screenshot 1 -


    - Screenshot 2 -



    Here are the project files, just unzip, load scene and hit play button. I would appreciate some feedback.

    Download:
    Tank Treads Simulation
     
    Last edited: Sep 17, 2012
  2. Novodantis

    Novodantis

    Joined:
    Nov 12, 2009
    Posts:
    95
    Very cool! Would be neat to control with two throttle axis'

    Also, I never noticed you could run a .unity3d by dragging it into a browser window. Learn something new every day =)
     
  3. Larsa334

    Larsa334

    Joined:
    Jan 7, 2011
    Posts:
    39
    Looks interesting!
    I will be following this t(h)read. :)
     
  4. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    I gotta admit, that is really cool! Makes a nice change from the usual use of physics being barrels and ball traps on chains.
     
  5. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Sorry for a bad link, web preview link fixed. Yes, two axis controls is the next thing to simulate before creating a tank model.
     
  6. cemC

    cemC

    Joined:
    Dec 23, 2010
    Posts:
    214
    it loks interesting. Do you share it ?
     
  7. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Ok, this is my first update of the project and the link for the new preview is on the top of this thread. Now you can steer the tank with WASD keys. I was thinking of creating a vehicle construction kit, the kit is going to contain cars, tractors, trucks, tanks, armored vehicles and some other stuff.
     
  8. ivanzu

    ivanzu

    Joined:
    Nov 25, 2010
    Posts:
    2,065
    Thats a great idea i like it a lot.The game is really good !!!
     
  9. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Update 0.3, added breakable tracks, wheels and some tweaking. Preview is on the first tread.
     
  10. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Hey is that a tank or a paper boat? Those treads break like paper! :D :D :D

    Fun stuff!
     
  11. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    You are right, I made them a little bit weaker so when you try the preview they would actually break. Just try to drive the tank over the obstacles and back, you must drive it a little slower.
     
  12. blackant

    blackant

    Joined:
    Jun 18, 2009
    Posts:
    529
    very nice project!
    don't know if turning is really break a caterpillar but it's fun.
    think of an explosion ...
     
  13. PolyMad

    PolyMad

    Joined:
    Mar 19, 2009
    Posts:
    2,350
    Ye I imagined it, just a joke :)
     
  14. ColossalDuck

    ColossalDuck

    Joined:
    Jun 6, 2009
    Posts:
    3,246
    I tried my hand at this, failed epically, and gave up... any tips?
     
  15. murkz

    murkz

    Joined:
    Dec 26, 2009
    Posts:
    19
    WOW Digital, well done :)
     
  16. sh0v0r

    sh0v0r

    Joined:
    Nov 29, 2010
    Posts:
    325
    Very cool Digital, is it fully physics simulated?

    It looks like all the track sections are using joints, how are you handling traction?

    Did you rig it up using Unity?
     
  17. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    this is very cool, made me laugh!
     
  18. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Thanks for the comments, yes it's fully physics simulated and 80% of the job is done in Unity and the other 20% is done by scripting.
     
  19. kshaja

    kshaja

    Joined:
    Sep 22, 2010
    Posts:
    148
    Bravo !!!
    This is so good!
    Its lot of fun.
    When and how are we gonna be able to play with it (not just in web player) ?
     
  20. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Thanks for the comments, I started this project because I wanted to create a tank simulation, now this is going to be a vehicle simulator.
     
  21. Vert

    Vert

    Joined:
    Mar 23, 2010
    Posts:
    1,099
    This is pretty cool.
    I think that the treads break way to easily though, they slip a lot as well. Other than that its fantastic!
     
  22. makan

    makan

    Joined:
    Jan 8, 2011
    Posts:
    342
    That was good start keep it up
     
  23. RingOfStorms

    RingOfStorms

    Joined:
    Oct 23, 2010
    Posts:
    584
    Awesome, one feature I may tell you to add is to lock the cursor and make it invisible, then just program the "esc" button to allow you to move it again.
     
  24. murkz

    murkz

    Joined:
    Dec 26, 2009
    Posts:
    19
    Any news please Digital.
     
  25. Colonel_Klink

    Colonel_Klink

    Joined:
    Jan 3, 2011
    Posts:
    76
    That's rather cool, mate. Well done.
     
  26. SkipKickCrash

    SkipKickCrash

    Joined:
    Oct 17, 2010
    Posts:
    80
    love the work, you get some awesome physic side effects which would be a nightmare to hard code (like loss of traction, wobbles and slipping)

    The tracks break very easily though, maybe someway to limit the amount of movement across the wheels would help reduce this, as it's the twisting force that most easily damages chains.

    How scalable do you think this approach would be? Could you have many tanks in one scene?
     
  27. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Thanks, there is nothing new for now but... I have reduced track breaking effect to a minimum so now the track should not even break. Number of tanks in the scene ??? This is going to be compensation between realistic behavior and performance.
     
  28. murkz

    murkz

    Joined:
    Dec 26, 2009
    Posts:
    19
    Is there an updated webplayer with the stronger tracks available Digital?
     
  29. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Not for now, currently I'm working on some other vehicles.
     
  30. thundercat

    thundercat

    Joined:
    May 9, 2010
    Posts:
    15
    Any news, Digital? Just had a play and it's fantastic. Would be great if the tracks are a little stronger so we can play with the handling a little more! :)
     
  31. VeganApps

    VeganApps

    Joined:
    Jun 30, 2006
    Posts:
    263
    I also played around with something like this some time ago. Once all the joints are set it is pretty easy to script.
    --Your current settings seem a bit too fragile to me.. --but if you don´t want ot create an action game it´s fine I guess.. :)

    Do you use WheelColliders for the wheels ? And how do you prevent that the chain rolls off the wheels ? With colliders or via scripting ?
     
  32. EpicTwist

    EpicTwist

    Joined:
    Apr 19, 2011
    Posts:
    83
    Make the tracks stronger therefore a tank wouldn't end up having them slip away from just a few bumps. Other than that, It's awesome!
     
  33. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    No news yet, I'm working on something else but... I have reduced track breaking to a minimum, there are no wheel colliders and I'm still testing tracks setup. Wheel colliders are the best for some racing games without obstacles, but if you open Unity's Car Tutorial and you put a obstacle in front of the car then you can see that this is not the best solution for some other type of racing/simulation game.



    Now I'm trying to create an off road vehicle without wheel coliders..
     
  34. MSylvia

    MSylvia

    Joined:
    May 19, 2009
    Posts:
    42
    Dual throttle would be great for Independent steering. How do you determine when the track should break?
     
  35. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Breaking is controlled with joint break force.
     
  36. EmadGh

    EmadGh

    Joined:
    Jun 10, 2009
    Posts:
    147
    I tried alot to do this with out wheel colliders, but I couldn't.
    I hope you find a way and let us now :)
    Thanks...
     
  37. VeganApps

    VeganApps

    Joined:
    Jun 30, 2006
    Posts:
    263
    Just use the WheelCollider.. ;)
    It is really the best bet to get realistic behavior.
     
  38. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,080
    Hi digital,
    first of all compliments for your work, well done, although treads break up too easily.

    Anyway, the problem you are experiencing with wheel collider is due to the fact that wheel collider still uses raycast to check collision with the ground, not spherecast or capsule cast. So it finds only one collision point vertical respect of the wheel.
    I worked a lot in order to fix this, and I developed a 3D tire algorithm, which finds all the contact points of the wheel, and I implemented it in my UnityCar package.
    If you are curious, you can check it by clicking on the link in my signature.
     
  39. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Heheh. very cool.
     
  40. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    about the wheel collider issue - it may be just as realistic to have a tyre collider just to prevent things like that. I used spheres. It works perfectly fine with wheel collider, but prevents the wheel from passing through things. It also helps bump the car up on obstacles.
     
  41. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,080
    Hi hippocoder,
    do you mean that you used a sphere collider or a spherecast?
     
  42. pepur

    pepur

    Joined:
    May 28, 2011
    Posts:
    31
    I want this physic in my tank :D
     
  43. Tactics_IT

    Tactics_IT

    Joined:
    Jul 29, 2010
    Posts:
    28
    I see its been some time since you have given a update. Just curious if you have and further progression on the tank part of this yet? That would be extremely welcomed right about now :D
     
  44. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Ahhh..... I've forgot about that, I'll try to find this project and when I do I'll post a project download link so you can see how does it work. I don't have time to play around with this.
     
  45. SnailMail152

    SnailMail152

    Joined:
    Sep 7, 2012
    Posts:
    21
    Even if its not a finished project I would really love to peak inside at the code and try to rework it to make my own tank game, which I haven't found much info about making the tracks actually move in a few days of searching. (Without being sent over to buy someone's 'package'...)
     
  46. SnailMail152

    SnailMail152

    Joined:
    Sep 7, 2012
    Posts:
    21
    Again I'm really looking forward to your reply and hopefully you will have found the scripts by then..
     
  47. Acelondoner

    Acelondoner

    Joined:
    Jul 27, 2012
    Posts:
    101
    Very impressive results. Keep it up mate!
     
  48. Digital

    Digital

    Joined:
    Feb 6, 2011
    Posts:
    182
    Here are the project files, just unzip, load scene and hit play button. I would appreciate some feedback.

    Download:
    Tank Treads Simulation
     
    Last edited: Sep 17, 2012
  49. Tactics_IT

    Tactics_IT

    Joined:
    Jul 29, 2010
    Posts:
    28
    Thanks for the project, i haven't had to much time to mess with it yet, but so far i have modified the tank.js script into 2 different script to control each track independently. Great job so far, my only problem I'm having is i cant seem to make the tank go faster. Like i said i haven't messed around to much yet. I now have the ability to do that thanks to you :)
     
  50. nockieboy

    nockieboy

    Joined:
    Jul 7, 2012
    Posts:
    48
    Hmmm.. just tried to download the project files myself to take a look but unless Dropbox doesn't like my Asus TF300 tablet downloading files, the link is broken?