Search Unity

[WIP][Released] WheelController - Realistic Three Dimensional Alternative to WheelCollider

Discussion in 'Works In Progress - Archive' started by NWHCoding, Aug 11, 2016.

Thread Status:
Not open for further replies.
  1. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692







    This thread has been moved.
    Click here for the new thread.






     
    Last edited: Mar 1, 2018
    AlanMattano, JamesArndt, jmjd and 2 others like this.
  2. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,764
    Very nice :) This will be a separate asset? If so how much will it be?
     
    Whiteleaf likes this.
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Yes. It will be a separate asset and planned to be out during the next week. Later it will be integrated into the new version of the Off-road Vehicle Physics Pack.
    Price will be somewhere between 10 and 20 dollars, not sure yet.
     
  4. Zac-Yeates

    Zac-Yeates

    Joined:
    Jan 23, 2015
    Posts:
    20
    I've been looking at 3d wheel colliders and it looks like this fits the bill perfectly. Does it work the same in terms of the default WheelCollider, as in inputs such as motorTorque and brakeTorque?
     
    Snorkel likes this.
  5. Fu11English

    Fu11English

    Joined:
    Feb 27, 2012
    Posts:
    258
    This looks useful. Is it possible to do non cylinder shapes. Like a more 'rounded' wheel for use with a motorbike that can lean etc?

    I used to heavily manipulate the old wheelcollider to give the effect of a full wheel shape, but it isn't really possible with the Unity 5 version :(
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Thank you on the info. I didn't know that was a problem in Unity 5 as I don't have any experience with motorcycles in games. Any (reasonable) wheel shape could be possible but the script would need to be modified in some parts as it wasn't build with motorcycles in mind. Will see what I can do about that.

    Edit:
    Tested it out just now and it mostly works (curved tractive surface) but I will not implement it yet as it does bring some bugs with it and I just spent whole day polishing things up :)
     
    Last edited: Aug 12, 2016
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    More interested in the integration with offroad vehicle pack as while I use edy's solution at the moment, I just generally like messing about with vehicle physics.

    As for requests, I suppose people will ask how to integrate it with existing vehicle packages.

    Our game is about arcade ish physics with a realistic feel, not sim :)
     
  8. Fu11English

    Fu11English

    Joined:
    Feb 27, 2012
    Posts:
    258
    Okay cool. If you could get it working I would happily buy it if suitable for my needs!
     
  9. slugxl

    slugxl

    Joined:
    Jun 30, 2014
    Posts:
    1
    It looks impressive. I look forward to your release and getting a chance to try it out. So far I have been focusing a lot on Wheelcolliders and have spent a lot of time feeling like I'm not making progress.
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    If a vehicle works with default collider it will work with this one as the getters and setters are covering the inbuilt wheel collider's variables (such as motorTorque, brakeTorque, mass, rpm, etc.). There are of course some differences in implementation and some tweaking will be unavoidable, e.g. curves are different, camber, etc.

    I'm currently working on API and custom inspector :), but it seems that this will be all for today as 14 hour work days aren't the healthiest....
     
    Cristineltr likes this.
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    A small sneak peek at what I'm currently working on... :D
    (yes, those presets can be changed at runtime)

     
    radimoto, JamesArndt and looki666 like this.
  12. hodge47

    hodge47

    Joined:
    Apr 14, 2014
    Posts:
    25
    I am definitely interested in this if it does work like the built in WheelCollider class. Im also making a motorcycle game and more of a curve on the sides would be nice in future updates. Ill be on the lookout for the package!
     
  13. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,932
    This looks outstanding! Kudos to a Unity 5 wheel solution that looks pretty robust so far. My question is a bit abstract. Do you think these might work for something like roller coaster rails? (i.e. better than the default wheelCollider which seems to not work well in my tests).
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    No, this solution is for car wheels only (and currently only cylinder-shaped ones). You could say that the main purpose would be for off-road vehicles and eventually road vehicles where it being 3D is a requirement. For a roller-coaster I think that the best bet would be simulating wheels but not actually having them as it's pretty specific (roller-coasters have wheels under and above the rail, e.g. cannot derail and so on).

    I am planning on 2 more ground detection modes besides the one featured in videos (which uses something like scanner to detect ground and then reiterate to get a better resolution of the interesting area). After spending almost two weeks trying out every method this turned out to be the best solution. But apart from that package will also feature a single raycast, Unity collider-like, solution and a spherecast.
     
    JamesArndt likes this.
  15. newlife

    newlife

    Joined:
    Jan 20, 2010
    Posts:
    1,080
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Upright, yes. Upside down, no. It has about the same limitations in the upside-down department as the Unity3D's wheelCollider as it is only sensing the ground under the vehicle - mostly for performance reasons.

    And as a side note, a new video will be out this week where I will test it a bit more rigorously than in the last (#3) one.
    Friction is mostly finished, along with suspension, custom editor and API.
     
  17. zugsoft

    zugsoft

    Joined:
    Apr 23, 2014
    Posts:
    453
    Really good , but do you a have a demo with high speed?
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    In the last video the friction aspect of the wheel was pretty much only a draft (hence the constant speed in the video), but just today I have finished that part and am testing it at both low and high speeds.
     
    Cristineltr likes this.
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Here is the new video as promised, hope you like it!

     
    eses, Cristineltr and jmjd like this.
  20. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    This looks like a really solid physic car solution, specially for off road.
     
  21. Cristineltr

    Cristineltr

    Joined:
    May 15, 2016
    Posts:
    13
    Looks very good
     
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Package has been submitted for approval and should be out during the following week. Many things have been polished / fixed / added since the last video and I'm finally satisfied with how it all works..

    You can try it out at wheelcontroller.tk

    Any feedback is welcome!
     
  23. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,764
    Your system looks very nice, but I can't use your demo when I click in the window the cars just drive off by themselves making them very hard to control.
     
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hmm. I can't seem to be able to replicate the problem. Could you please tell me what browser and OS you are using?
    And does anybody else have this problem?
    I see no way how they could drive of by themselves, except if the one of the direction arrows was pressed.
     
  25. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @NWHCoding

    Looking good. Like the video, however, when I tried the web player demo, car feels very much different what I would expect to see based on watching the video first.

    A. It's quite easy to flip the car, pretty much the same way Unity wheel does, but in this case seems like suspension settings are way too bouncy for both of the cars.

    B. If I get the car on its side, or drive on diagonal surface so that one or two wheels barely touch the ground, I get "flickering" wheels i.e. wheel goes up and down without being able to decide where to be.
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I have re-uploaded the demo with Input.GetAxis() replaced with Input.GetKey() and manual lerp. It is possible that your device has accelerometer and as such Input.GetAxis() detected this as a valid input. Now the vehicle will move only if using arrows or WASD.

    Thank you on your feedback.

    A. Spring and damper calculations are physically correct so the reason why the car flips so easily is mostly due to high center of mass and it not having anti-roll bar applied. I have written the script but wasn't going to include it since it is something that would fall more under vehicle controller side of scripting, but now that you mention it I will add it.
    I have rebuilt and re-uploaded the demo with higher damper settings, they may have been too soft but it was more to showcase the "bounciness" :)

    B. Vehicle on the side problem with flicker is a very-much ongoing issue (same as with the inbuilt wheel collider). As with the wheel collider, easiest fix is to disable suspension while vehicle is tipped over. Im working on fixing it tho now that more pressing problems are done away with.
     
    Last edited: Oct 24, 2016
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Wheel flicker when vehicle is tipped over has been fixed in the newest build. I just uploaded the new demo.
     
    eses likes this.
  28. eses

    eses

    Joined:
    Feb 26, 2013
    Posts:
    2,637
    @NWHCoding

    Demo feels a lot better now. Based on quick test, I really dig the way vehicles behave.

    I'm curious - are you also going to release some car/vehicle asset too or just the wheel collider?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Thank you. I really put a lot of my time into it so I am glad it was not in vain, and most of the time it was fighting Unity3D limitations.
    I was just working on vehicle asset when I realised that I don't quite like the non-customizability and behavior of the default wheel so I started WheelController as a side-project that in the end ate up better part of free time through summer. Vehicle asset will be out sooner or later but I would rater not give any time frames.
    Until then there is my older package Off-road Vehicle Physics Pack which is a bit long in the tooth and due for an update.
     
    eses likes this.
  30. ilesonen

    ilesonen

    Joined:
    Sep 11, 2012
    Posts:
    49
    Hi,
    I've been looking forward this asset, so what is the status, Is this going to be available soon? It is looking really promising system!
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Code has been finalized for the v1.0. I have done a lot of testing and after being happy with the result, submitted the package for the review. Now it's in Unity people's hands, and has been for the last two weeks. So as soon as they do the review it it will be available in the store.
     
    AlanMattano likes this.
  32. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    This collider uses a mesh for collision ?
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    No. It uses raycast. Mesh detection would mean loading all the meshes that are viable for collision, convert each vertex of each mesh to world space (as well as the wheel's mesh), find closest contact point and then pass that as the point of colision. That can get into the millions of vertices per frame since you would have to load the whole terrain, amongst other things.If Unity3D allowed devs to access spatial data, spatial scan would be the best option. But since they don't, of all the methods only raycast is viable at the moment performance and behavior wise.
    In the online demo each wheel uses 20 raycasts, which is really not much since raycast are very well optimized in Unity3D. As a result, both vehicles in the demo scene use up less than a 0.5ms CPU time combined on my average PC.

    Here is the excerpt from the documentation that explains it more into more detail:


    "Firstly, a number of rays are cast towards the ground from the calculated origin. Of those rays that do indeed
    hit one with closest distance is selected and if scan depth is set to more than 1, scan is repeated but only in the
    area between the previous and the next ray from the one that was selected as best candidate in the previous
    step. Deep scanning is mostly not needed, but in cases where there might be sharp or thin edges over which a
    wheel will pass it will improve detection and reduce possible jitter.
    Due to performance reasons rays are kept as short as possible meaning that they will never extend more than
    the wheel is able to travel – and because of that there is a low performance impact even with high scan
    resolutions. E.g. to do a complete wheel scan with 100 rays (which is overdoing it), script will use up 0.35ms of
    CPU time per wheel on an Intel Pentium Dual Core 3.2GHz machine, and of those 0.35ms 0.25ms is spent on
    raycasts. For default values which are more than adequate in most cases script will use 0.19ms per wheel, of
    which 0.12ms for raycast. So the average time for one raycast in this case is about 0.003ms."
    And to help visualize:



     
    Last edited: Nov 12, 2016
    AlanMattano likes this.
  34. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    246
    Any news on release on this? I'm quite keen to replace the 'infinitely small' wheels that Unity uses by default.
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I have submitted this package for a review more than two weeks ago. Guys at Unity sure are taking their time to review it. As soon as I have any updates I will post them here.
     
  36. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    He
    Hello, will be this wheelcollider a part of your Offroad vehicle kit? I have just bougth it hoping that I find this wheelcollider in package. And I was very disappointed, there is no your magic wheelcollider...
     
    Last edited: Nov 16, 2016
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    It does not come with it, yet, and nowhere is it written that it does come with it. But I can offer you a refund if you misunderstood - I dont like unsatisfied customers :).
     
  38. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    If I'll buy current Offroad Vehicle kit, then after when you complete your wheelController, you're include it to OffRoadVehicleKit and I'm simply update and get it? Or you will upload a new asset, Could I update asset without waste extra money?
     
  39. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    First, note that there might be a longer delay between releasing the WheelController and the update for the Off-road Vehicle Physics Kit as I am doing an overhaul of the OVPK. Users that bought OVPK without the WheelController will be offered upgrade for a price when WheelController gets included.
     
  40. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,488
    Hi, looks nice! when do you expect this to be available as an asset? I could use it to update my Rock Crawler game asap! :)
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Well, they just approved it and it is avaliable at Unity Asset Store.
    Took them tad over three weeks.
    Have fun rolling :)
     
    Last edited: Nov 17, 2016
  42. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    You OVPK is very good so I think I don't want my money back:)) But it also depends of price. What like it will be?:) And you url don't work.
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Link fixed, thank you for the heads up.
    I cannot talk about pricing of the upcoming package since I myself don't know yet, but you cannot expect the car to be cheaper than the wheel itself... :)
     
  44. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    Ofcourse:)) Link is on now. Oh my god. I can't wait, I want his package! I want my money back to spend them for this magic!:)))
     
  45. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,488
    Wow, cool! Is there a tutorial video on how to setup? I use existing wheel colliders, it is easy to replace with your script? I want to check how easy it is to integrate your asset into an existing game.
    I assume no, but to check, is your wheel collider simulating softbody physics at all?
     
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    No, no softbody physics at all which makes it work well on mobile.
    There is no tutorial video but there is included manual. I will do a video tutorial this weekend tho.
    As for how easy it is to integrate: If you have a pretty basic vehicle setup what you would need to to is replace the WheelCollider with WheelController. Defaults are already set up when you do it, but do check if something needs setting up by hand (e.g. assign parent rigidbody). Next step would be to find and replace all the wheelcollider lines with wheelcontroller like so:

    public WheelCollider leftWheel; => public WheelController leftWheel;
    After that it should run with no error codes. If you are evaluating wheelcollider's friction curves, you can do a similar thing with this asset too (there is a full access to everything friction-related via the API, including the curves) - but it might need some tweaking because of difference in curves or etc.

    TLDR; If you replace the WheelCollider with WheelController it will work out of the box 80% of the time. while 20% of the time it may need some small code changes.
     
  47. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    So what I can tell you about this pack, it is amazing! But I spent many hours trying to set frictions. And I can't. Yes, there is diferences beetween snow, alphault, ice. But it is not possible to make a car steer without sliping like on some slippery surface. May be there is a reason how to make it stable? I am a driver myself so I think cars don't slip so on asphault like on ice.
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Have you tried changing the force coefficient to a higher number?
    Friction curves are a reference for a standard (generic) tire, and to change how grippy the tire is you change the force coefficient. Try setting it to 1.5 or even 2 to see if you like the result. Force factor basically affects how much force a tire can put down before losing traction.

    Also, I have done most of the testing with both keybard and a gampad. Problem with keyboard is that it is a binary input (either full left or full right) so when you press the button it is equivalent to suddenly yanking the wheel to one side and at 100kph doing so would certainly result in some slip. To minimize this change the "Min Steering Angle" on the CarController script to a lower value and see if you like the result.

    Hope this helps!
     
  49. khos

    khos

    Joined:
    May 10, 2016
    Posts:
    1,488
    Thanks for the info, can I use the existing wheelcollider properties in my code too, or does your script use other names? My game references existing wheelcollider properties to control suspension/size etc. Will I need to adjust that if using your script?
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Here is the API Reference included with the asset so check out available properties and see if they suit your needs:
    API Reference v1.0

    If you used only basic properties then you will be able to use existing properties. If you have anything friction related or use some more advanced properties - while similar - those might need adjusting.
     
Thread Status:
Not open for further replies.