Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Vehicle Physics Prototype

Discussion in 'Works In Progress - Archive' started by JustInvoke, Feb 16, 2013.

  1. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Last edited: Jun 23, 2013
  2. Venged

    Venged

    Joined:
    Oct 24, 2010
    Posts:
    500
    Very nice!!
     
  3. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Thanks, any criticisms?
     
  4. Roylen

    Roylen

    Joined:
    Jan 22, 2012
    Posts:
    24
    Hey RandomationGames,
    Totally cool vehicle physics you have there. I spent half an hour playing it :D
    For a first build its quite nice..

    and yes i found something unusual..
    You know that large plane slope (the steeper one) next to the little mountain pass if you go left from the spawn point.... If you drift on that slope the skidmarks become very fat...


    http://s18.postimage.org/5bjd69jqh/chrome_2013_02_16_12_46_46_61.png
     
  5. suctioncup

    suctioncup

    Joined:
    May 19, 2012
    Posts:
    273
    Your game is going to be extremely fun! It was awesome just driving around in the demo scene.

    Please sell this for around 20-$30! I'd love to have it!
     
  6. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Yes, I am aware of this, it's on the list of known issues on this page. It's because the slope is non-uniformly scaled, and the tire marks are parented to whichever object they are left on. This makes them stretch oddly.

    I hope to get enough content into the final game to warrant a price like this.
     
  7. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    I've added a muscle car to the game for testing, it will be in the final game. I would have had it done sooner, but I was experimenting with an unsuccessful damage system. I've decided to leave it our entirely because it was buggy, slow, and it would take way too long to make it work for each vehicle. Plus it was almost a nuisance because because running over bumps and scraping the walls would mess up the vehicle, and I want the game to be about swimmingly darting around the environment. Before I create nice versions of the other vehicles, I'm going to texture this one and polish it up with better sounds and shaders.
     
  8. Djiel

    Djiel

    Joined:
    Jun 25, 2012
    Posts:
    108
    That was pretty fun. Reminds me of parts of Crashday, minus the guns.
    I tried the plain car, muscle car and f1 car, since these are the most like what I'm looking. I like the driftiness it has (once you tap the handbrake)
    Only critique I would have is; the huuuuge understeer (on these cars) and the crazy low gravity.
     
  9. zulukogaming

    zulukogaming

    Joined:
    Jan 24, 2013
    Posts:
    16
    Very fun physics engine, this could create a great game! I did see a bug with the boost button, rapidly pressing the boost button on some vehicles (most notably the motorcycle and single axle allows you to greatly exceed your max speed. Driving a single axle at 400 mph is fun, however not so realistic :).
     
  10. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Playing around with it some more, I think you're right. Soon I'll update it and give the cars sharper turning radii as well as make them fall a little faster. It's strange because the gravity is set to the default -9.81 and everything is scaled properly.

    This is because pressing the boost button gives you a brief burst of speed. I'm planning on limiting how quickly the user can boost repeatedly.
     
  11. Roylen

    Roylen

    Joined:
    Jan 22, 2012
    Posts:
    24
    Actually don't limit how quickly user can boost... rather boost (N2O) usually is used to increase acceleration so that top speed is reached more quickly (according to my experience with racing games). So maybe stop the effect once top speed is reached. Just a suggestion you can decide what is best :)
     
  12. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Okay, I've made the vehicles handle a little sharper, fall a little faster, and limited how quickly the player can boost above top speed.

    I wanted players to be able to do this. After reading your post, I've decided to not limit how quickly the player can boost, but rather disable the initial speed gain once the player reaches top speed. However I've left it where you can still travel just a bit above top speed with this technique.
     
  13. Roylen

    Roylen

    Joined:
    Jan 22, 2012
    Posts:
    24
    It feels so Burnout style :D
    Every time I open the webplayer I keep on playing for a long time. The physics are quite fun. :)

    Btw, I found another bug.
    I landed the car (i tried the muscle car) on its roof, so that the wheels were free from any contact, then when i held handbrake and accelerated/reversed, the rear wheels rotated in opposite direction from each other. Weird.

    And the way the camera 'snaps' when the car enters a slope (or maybe the car re-aligns itself) is quite distracting. Specially when i drove the car on the uneven terrain at high speed.

    another thing, are you going to give unlimited boost?
     
  14. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Thanks, Burnout Paradise was actually the biggest inspiration for the physics.

    I've now fixed the wheel spinning bug. And I think the camera snapping is a result of the way the camera switches into an airtime mode. I could put a delay on it so it only initiates on large jumps.

    I'm currently working on the visuals and materials, and I might not update it until I'm through with this.

    As far as unlimited boost, I might copy the speed or locked boost types from Burnout, if you're familiar with those. Soon I'll add a boost bar and allow people to earn boost with airtime, stunts, and drifting, plus oncoming once I make a city environment.
     
    Last edited: Mar 12, 2013
  15. carking1996

    carking1996

    Joined:
    Jun 15, 2010
    Posts:
    2,608
    The webplayer says when I click a button to start, it can't load because of a content error.
     
  16. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    It seems to be working for others, I've reuploaded it now.

    EDIT: Actually, I'm having troubles too. I'm away from home and don't have a good enough connection to upload a new build. At latest, the 15th is when I'll be able to fix this.
     
    Last edited: Mar 13, 2013
  17. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Okay, I've uploaded a new build. Sorry for the delay, I've been trying to smoothen out the camera movement and it took longer than I thought it would. Now I'll continue with the visuals unless something else game-breaking pops up.
     
  18. jakobdzl

    jakobdzl

    Joined:
    Nov 11, 2012
    Posts:
    7
    just checked out the web player this is very fun! are you using ray cast?
     
  19. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Raycasts are used for a variety of things in this. The wheels are based around Unity's built-in wheel colliders.

    On another note, I know it's been about two weeks since an update. I've been working on the visuals and sounds quite a bit, but only for the muscle car. In the next week or two I should have it ready.
     
  20. blaize

    blaize

    Joined:
    Jul 25, 2012
    Posts:
    41
    I love how you've setup the motorcycle! I've been playing with motorcycle physics myself before, but bumped into an issue with balancing the motor in corners.

    Care to share some info on how to setup yours?
     
  21. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    I struggled a lot with this too. Basically it's a matter of constantly altering the friction of the wheels and applying torque and other forces to keep it balanced. The steer angle of the front wheel collider becomes useless once the bike tilts, so as the bike speeds up, it is forcibly rotated and moved in the direction of the turn with functions such as Addtorque and AddForce, and their local space equivalents. For tilting, the bike must first determine its target leaning direction. This takes the average normal of the surfaces the wheels are sitting on and adds the local forward and right vectors by variable amounts depending on factors such as how hard the bike is turning and accelerating and whether or not the player is trying to pull a wheelie. Once the target direction is determined, the function AddRelativeTorque is used to try and tilt the bike to point its local up direction towards the target direction. The velocityChange forceMode was used for this. The tilting was particularly difficult as the bike would often overcorrect when leaning, leading to quick oscillations. The unicycle and monowheel used a similar method of balancing, except with different calculations on the local x-axis. To turn the single-wheeled vehicles, I simply rotated them directly on their local y-axis.

    The code is fairly long, and it's hard to sum it up here. It just takes a lot of trial, error, and persistence. The motorcycle was the hardest vehicle to make in this test. The single-wheeled vehicles were a little easier only because I had a balancing mechanism in place from the motorcycle.
     
    Last edited: Apr 17, 2013
  22. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    The graphics and sounds of the muscle car have been improved, and you can now pop your tires by driving over the spike strip near the spawn point.



     
    Last edited: May 30, 2013
  23. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    The monster truck has been upgraded.




    Unfortunately, I have decided to cut the double and single-wheeled vehicles from the game. This is mainly because of quirks in their gameplay and the fact that I would rather put my time into creating more vehicles than trying to configure rider animations and ragdolls. I have also removed the interior from the muscle car and will not be adding interiors into future vehicles. This is just part of the process of finding my limits and controlling my ambitions. I would rather have more cars and trucks than say, one motorcycle, one monowheel, one truck, one supercar, one muscle car, etc. (Edit: This might end happening anyways.) We will see how it pans out, as this is my first Unity game. More cars are on the way, though.
     
    Last edited: May 27, 2013
  24. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    The F1 car has been upgraded.





    I'm planning on adding 3 or 4 more vehicles to the demo before moving onto the HUD and AI.
     
  25. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,255
    Very nice, are you planning to sell it on the asset store or is it for your personal project?
     
  26. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    It's for my own project. The final game will be commercial though. The code isn't very suitable for selling as there are quirks and messy parts. Once the game reaches alpha, I'll make a new thread for it with its proper title, but that's at least several months into the future.
     
  27. FlaxSycle

    FlaxSycle

    Joined:
    Oct 6, 2012
    Posts:
    232
    Woah, that's really fun, really tight controls too!

    You're onto a good thing with that style of visuals, the cars feel so clean and crisp
     
  28. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Thanks, the visuals should develop more once the environment becomes more stylized. They are based around Unity's built-in toon shader with some modifications.
     
  29. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    The 3-wheeler has been upgraded.



     
  30. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    A cop version of the muscle car has been added, complete with functioning sirens and lights and the ability to drop spike strips. Dropping spike strips will become more useful once I add an LOD system so that players can spawn multiple cars. You can also dim the lighting now.







     
    Last edited: Jun 16, 2013
  31. Divinux

    Divinux

    Joined:
    Jul 5, 2011
    Posts:
    205

    Seconded. I love to drift around with popped wheels and do that for ages every time you post.
     
  32. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Thanks, I guess that means the gameplay is addicting, which is what I was shooting for. I have just two more vehicles to add, then I will work on the HUD and s̶t̶u̶n̶t̶ ̶d̶e̶t̶e̶c̶t̶i̶o̶n̶,̶ ̶s̶o̶ ̶y̶o̶u̶ ̶c̶a̶n̶ ̶e̶a̶r̶n̶ ̶b̶o̶o̶s̶t̶ ̶b̶y̶ ̶l̶a̶n̶d̶i̶n̶g̶ ̶s̶t̶u̶n̶t̶s̶.
     
    Last edited: Jun 16, 2013
  33. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    The hover car has been added back into the game. I have decided to hold off on adding more vehicles for now in favor of working on the HUD. I'm getting a bit fatigued with vehicle creation, and I feel like I need to see other aspects of the game grow in order to stay motivated. I'm tired of driving around in this diffuse-shaded, grid-textured area of planes and primitives with bland text representing the HUD. Don't worry though, I will still add more vehicles at some point, but they might only make it into the final game instead of this demo.





    Here is a time-lapse of the creation of the hover car from start to finish:

     
  34. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    The HUD has been added to the game, including a minimap, boost meter, and indicators of how long your drifts and jumps are. You can no longer infinitely boost, and a few different boost types have been introduced. The first one is normal boost, where you can boost whenever you want so long as you have boost in the meter. The muscle car, 3-wheeler, and hover car use this type. The second type is one-shot, where you can only boost when the bar is full. Once you boost, all of the boost is used up in a quick burst providing great acceleration. This type of boost also fills up quicker. Both the monster truck and cop car use this type. The third type is chain boost, where you can again only boost when the bar is full, but you can drift and jump while boosting to fill up a secondary meter. If this meter is full when your boost runs empty, it will automatically refill so you can continue boosting and build up a boost chain. Only the F1 car uses this type. There are two other boost types I'm saving for the full game; I'm open to suggestions for more.



    Unfortunately I will not be adding a robust stunt system because it is out of my skill level. The game still detects drifts and jumps though. The next update will include an LOD system and possibly AI for other cars.

    A standalone Windows version is also available. I would appreciate it if people could tell me how well both the standalone and webplayer versions perform and if there are any particular slowdowns.
     
    Last edited: Jun 16, 2013
  35. Roylen

    Roylen

    Joined:
    Jan 22, 2012
    Posts:
    24
    Woah Random visited the forums after so many days just to see your progress.... Wow! its becoming better and better.. Keep up the hard work... Goodluck !! :)
     
  36. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Thanks, today I just uploaded a new build with AI and and LOD system. You can spawn up to 5 other vehicles which can either chase you or run away. Having more than this would slow the game down too much, however I have some optimization ideas which I cannot implement until I make progress on the full game.



    This will probably be the last update I make to this demo. Once I have some sort of a pre-alpha demo of the full game ready I'll make a new thread for it. In the meantime you can check out periodic updates on my blog and Youtube channel.
     
  37. Divinux

    Divinux

    Joined:
    Jul 5, 2011
    Posts:
    205
    Yeah I noticed before you made the post. Spawned a fleeing car, it spawned, made a left turn into the flipper and was never seen again :I

    I would love for the drift counter to display the longest drift in the playsession or something, got it up to 3000 yards. A tiny grace period would be lovely too so you can transfer from left hand drift to right hand instead of going in circles ;)

    Also, because I didn't comment on the previous video, pretty awesome to see it done in SketchUp. Didn't know one could even do stuff like that there. Best I could get were cubes. Why aren't you using Maya/Max or Blender?
     
    Last edited: Jun 24, 2013
  38. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    I'll admit the flee AI isn't very good, since fleeing cars will just try to run straight away from you and often get stuck against a wall. In the full game I'll try and work on some sort of a waypoint system wherein AI cars can choose specific paths to take through the environment as they run away.

    I agree about the drifting thing, and I've decided to add in a tiny grace period where you can swerve the other way and continue the current drift. I might even try to have it recognize the number of individual drifts you chain together. In the full game I'll add in the typical stats screen that shows your best records as far as drifting and jumping. There will not be online leaderboards.

    As for modeling with Sketchup, I choose to use it because it's what I'm most familiar with. I first tried it on a school computer about 4 years ago and have stuck with it. I use Blender for texturing and making small adjustments where necessary. I also use it for rigging, but I really don't like to rig models, luckily with this being a car game I don't really have to rig anything. One of these days I might fully transition into Blender, but it can be a pain to use at times and there are some things I just like more about how Sketchup works.
     
  39. Divinux

    Divinux

    Joined:
    Jul 5, 2011
    Posts:
    205
    I know what you mean, I learned on Maxon's Cinema 4d, and have been transitioning to 3ds Max because it has more powerful tools for modelling and uv mapping, but even though I know it has all this incredible stuff everything I do feels weird and just a bit "off". I'm guessing it has to do with different workflows which we are simply not used to, and it's hard to switch to a new workflow mentally to fully utilize all it's power. In any case, good on you for mastering a piece of software to the point where you can manipulate objects the way you want to, and it's amazing to see as someone who is trained in a more "classical" polygon modelling.
     
  40. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Thanks, I know Sketchup isn't really common for game modeling.
     
  41. Zeblote

    Zeblote

    Joined:
    Feb 8, 2013
    Posts:
    1,102
    The hover car is really fun to drive around
     
  42. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    I realize I am almost a year late - but hey hope your still working on this project - it is a fun webplayer and has potential!
     
  43. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Unfortunately I've abandoned it, but the physics are available for sale.

    Someday I would like to use these physics in an open world game again, but I would definitely redo the models and add a damage system if and when I do it.
     
  44. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    Ahh OK, well cool I'll check it out!
     
  45. RenegadeScooter

    RenegadeScooter

    Joined:
    Feb 18, 2017
    Posts:
    4
    Hi, I was wondering if you could make the Vehicle Test Prototype open source on GitHub so that I can play around with the different cars and import my own. Thanks! ;)
     
  46. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    375
    Sorry but I can't do that. I haven't touched this project in years and it's very poorly written because of my lack of experience at the time. The newer version of my vehicle physics is available though.