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
    There will be a small update as soon as it gets approved.
    If anyone wants it earlier send me a PM with an invoice number and I will email it to you.

    • GetGroundHit(out hit); and WheelHit struct have been updated to be as similar as possible to the GetGroundHit function and WheelHit struct from the inbuilt package + some other minor API updates.
    • Improved spring / damper stability.
    • Some tweaks to the demo scene.
    • Bug fix for the ray length calculation (performance update).
     
    Last edited: Nov 20, 2016
  2. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    How to make an invoice number or how to purchase it before gets approved ?
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Package has been out since Friday (see beginning of the first post). What I was talking about was an update from Saturday and updates are free once you get the package from the asset store : http://u3d.as/Cu6
     
    Last edited: Nov 21, 2016
    AlanMattano likes this.
  4. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    Guys, I found minor bugs. One of them is that radius of rim can not be set from wheelcontroller script, it always come with standart valie on start. I fixed that. As soon as posible there will be a little game video. It is amazing asset!!
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Thanks for the heads up, Ill see that fixed.
     
    AlanMattano likes this.
  6. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    And it will be better if user can himself set up a layer for wheelcontrollers because of many layers in big project like mine. Wheelcontrollers ignore layers from 0 to 20 that I anderstood. But I have more than 20 layers so they make a collision with other parts of game. I wrote it for me:) Thanx:)
     
  7. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    Little radius of rim make car jittering. Bigger radius than it must be make spring not compress like it must, it makes it like wood sticks after jump from hills. Stronger stifness makes car slip down, there is must be some stabilization. I wrote it too:) It is a post for people who have a broblems with it:)
     
  8. Dennis_eA

    Dennis_eA

    Joined:
    Jan 17, 2011
    Posts:
    380
    Hi NWHCoding, I've tried your demo.

    I tested it simultaneously on my MacBook Pro Late 14 and iMac, knowing that such a scene wouldn't run super smooth on my laptop. It works okay, but the problem I see is, that your mechanics are very dependent on stable FPS and also keeping up with your fixed time steps (I guess these are set to 30 or 60hz).
    Your approach seems to be interesting, but you should focus more on creating reliable and 'solid' mechanics, so that similar ('same' is not possible, yep..) results can be expected, on different devices with different specs. I think, this is _important_. Nothing is more frustrating than not being able to predict how the car is behaving - making it useless at higher speeds*
    If you haven't done this yet, just let me give you this tip: try different devices, try different time(step)-settings and also different targetFrameRates; that way you can see which thing really Do work or not.

    *Of course, the problem I mentioned gets bigger with *speed*. I can imagine, your approach is good for some kind of rock crawler game. But you also put some sporty Jaguar in your scene..
     
  9. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    To predict how car will behave in higher speed it is not anought to use this asset from box. It is all in your hands. Have you tried yet builtin unity wheelcollider? It is more laggy and car behave horrible.
     
  10. Dennis_eA

    Dennis_eA

    Joined:
    Jan 17, 2011
    Posts:
    380
    I disagree, and yes I've spent a lot of time with the U4 WC, U5 WC and at the Moment I am developing my own custom made physics. My post was meant as a tip.

    Thats a question that could arise from a potential customer: why didn't he 'fine tune' his asset, so it is running smoothly* in the webplayer on a decent laptop.

    * Reliable physics even when fps drops do or can occur.


    @NWH:
    Again, I didn't want to offend you. I like your work, but I think it's really important to test different scenarios (devices, timesteps ..) That is something no one told me, when I started playing around with PhysX in Unity a few years ago.
     
    Last edited: Nov 25, 2016
  11. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    Noone play games on pentium 3, 700mhz:) And it is anougth builtin wheelcollider for mobile games. So I don't understand people who want unreal perfomance for code. Absurdly. It is not musthave now. Computers are fast anought.
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    The problem you have is probably mostly due to the WebGL player being AWFULLY slow at the moment. I need a GTX950 to even run an empty scene with a single terrain at 120fps (no scripts). I am really considering downgrading and uploading an old web player demo.

    My asset works with default timestep (0.02) no problem (as far as I tested it), and of course it would be dependent on the time step since physics calculations are generally time dependent. I did compensate for different framerates and tested it from 30 fps to 500+ fps.

    The thing you are mentioning with high speed - to me it seems like you might be actually using keyboard to steer (abrupt steering will cause instability at high speeds - don't try doing that on a highway in real life). Another thing is the forceCoefficient of the wheels - this can be adjusted and is set fairly low in the demo to allow for drifting.

    If you want i can PM you a built package for your desktop computer / laptop for you to test since WebGL is pretty bad at the moment.
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Rim radius doesn't do much except for when the vehicle is tilted over or vehicle is falling at very high speeds where raycast may pass through the floor. Other than that it is just a value that determines the width of rim collider.

    Not sure what stiffness we are talking about? Spring? Damper?
     
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    New update (1.1) is out with a few bug fixes and API changes.
    The WebGL player in web demo has been replaced with the Web Player for performance reasons - it should work better now.
     
    Last edited: Nov 28, 2016
  15. marvin-true

    marvin-true

    Joined:
    May 5, 2014
    Posts:
    10
    Spring is soft car came from jump. When it collide the geound if rim is more then it must be, car spring behave like wooden stick
     
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Thank you for the heads up, I will check it out. It would be great if you could tell me what the rim and tire radius settings were and the height the vehicle dropped form.
     
  17. hodge47

    hodge47

    Joined:
    Apr 14, 2014
    Posts:
    25
    Hi there. Im coming back to this post because I am extremely unhappy with Unity's built in wheel colliders. I just have one question. How well do you think this would work for two wheeled vehicles? In all of the demo videos I saw only 4 wheeled vehicles being used. Just wondering If its dependent on N pairs of wheels being parallel to each other.
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Update:
    If you have Unity 5.5 you might experience some oscillations, I am currently working on the fix.
    Went through the patch notes and nothing that would make that happen, but they did change something.
     
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Update 1.3 is on its way and has already been submitted to the store.
    Fixed any oscillation / jitter / shaking problems.
     
  20. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    Hello. How I can set visual wheels via script? Get/set construction don't allow me to do it.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    WheelController.Visual = someWheelGameObject;

    It's right there, easy to miss tho :D
    Take a look into API Reference that is included if you don't like to sniff around code.
     
  22. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    Ok, we resolved problem. We made new class instance and assign it to a wheelcontoller.wheel.
    Code (CSharp):
    1. wc.wheel = new WheelController.Wheel ();
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    If you need help with something else, send me a PM with the piece of code in question so I can see what exactly is happening. I am not exactly sure why you would want to instantiate WheelController.Wheel()? It is a sub-class of WheelController and once you have WheelController if you don't want to use Editor you can simply set all the variables via the API. E.g.:
    wc.tireRadius = 0.5f;
    wc.Visual = leftTire;
    ...
    Not sure what you would need a new instace of WheelController.Wheel() without it's parent.
     
  24. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    Hello again. I don't understand how to set visual wheels through code. So I have script-configurator, which adjust our car, place rigidbody, create colliders, setup active suspension and etc. But one thing I can't produce correctly setup visual wheels and rigidbody parent. ?!.
    Our hierarhy is. In Visual_Wheels we have our geometry of wheels at Wheel_Contollers, empty gameobject with Wheel_Controller script.
    123.PNG empty.PNG
     
    Last edited: Feb 1, 2017
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Please use email for support so I can attach code.
    I would reccomend you do not use debug mode as you are for assigning values, there is a custom inspector to simplify that. As for assigning visual - just drag and drop your wheel transform, drag WheelFL to the visual field in the inspector. Thats it. It is just there so you dont need to changes position of your wheels manually, but if you want you can leave visual field empty and simply do it as you did with inbuilt wheelcollider over GetWorldPose(). Parent and parent rigidbody are the same gameobject.
     
  26. Danua

    Danua

    Joined:
    Feb 20, 2015
    Posts:
    197
    We want setup wheel via code, but we can't.
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    You could send me your scene and I will check it out.

    Here it goes:

    leftWheelController.Visual = GameObject.Find("Aspid/Wheels_Holder/Aspid_w_0/Visual_Wheels/Wheel_FL");

    Instead of GameObject.Find() you could assign it directly if you already have a variable reference to it somewhere in code, such as

    public GameObject WheelFL = [your code for retrieving game object];
    leftWheelController.Visual = WheelFL;


    Or you could do it manually and not assign anything to "Visual" and do it just like with the Unity3D's wheel collider - there are many tutorials about that but something along the lines:

    Vector3 position;
    Quaternion rotation;
    leftWheelController.GetWorldPose(out position, out rotation);

    yourWheelObject.transform.position = position;
    yourWheelObject.transform.rotation = rotation;

    (check out https://docs.unity3d.com/Manual/WheelColliderTutorial.html , same principles as here)

    All three examples are pretty basic and also check out supplied API reference to see what you can assign and in which way. Exactly this is why I made WC3D's API as similar as possible to the inbuilt wheel collider.

    I would recommend checking out Unity3D tutorials and OOP references in general because all the concepts in here are very basic Unity3D programming.
     
  28. davidfrk

    davidfrk

    Joined:
    Feb 13, 2017
    Posts:
    43
    How can I prevent the vehicle from sliding on a slope?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Much like with Unity's wheelcollider you cannot. Due to slip being calculated reactively (wheel must slip first for slip value to be known and then adequate force to be applied) perfect stillness cannot be ever achieved - or at least not with this method as vehicle will always slip a bit. This is also due to Unity physics running at 50Hz by default where delta time is about 0.02 so it means that vehicle will have 0.02s to travel freely before any force can be applied as a reaction.

    Slip can be reduced by increasing the slip coefficient in the script but if you overdo it you will get over-reaction and vibration.
     
  30. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    I think you should make a complete vehicle physics using this asset.
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Well, that certainly is the plan and I posted a little video on YouTube showcasing what has already been done. In a few months I will be getting my masters degree so I will be able to dedicate my full time to new projects so they should roll out much faster :)

    In the meantime I do believe that there are many people with projects already set up that want only to changes the wheels and have one of the vehicle packages already.
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    I was on my mobile so I didn't post the link to the video.


    It was a month ago and with the pre-release version of WC3D - and it's just a sketch.
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    New demo video for v1.6:

     
    JamesArndt likes this.
  34. hodge47

    hodge47

    Joined:
    Apr 14, 2014
    Posts:
    25
    Hi!
    I have a request; I am having a problem with the rim collider hitting the ground when my wheels are leaned over (motorcycle game). Making the rim colliders smaller so they wouldn't touch did some weird things. I am requesting an addition of rim collider width adjustments perpendicular to the wheel itself or maybe the option to disable the rim colliders in future updates if possible.
    Thanks!
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    No problem. Rim collider is a safeguard more than anything else (after v1.0) and if you are willing to change the code removing it cometely should be no problem. I will probably remove it completely in 1.7.
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    New update on the way (v1.7). Changes:
    - Option to disable rim collider.
    - Optimization (about 20% performance increase).
    - Bug fix with slip in reverse being to high (bug from v1.6).
    - Tweaked default Tarmac curves.
     
  37. AlanMattano

    AlanMattano

    Joined:
    Aug 22, 2013
    Posts:
    1,501
    The movement looks perfect but wheels now look rigid. Are you thinking to include a mesh wheel deformation as an option to the asset?
     
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Not soon, no.
    There are a few lines that did the fake, non mesh, deformation effect from the early videos since I was not happy with it I removed it, and if you want it I can send you a version with it.
    Wheel mesh deformation brings a lot of problems with it, such as performance, having to have fitting models with tire and rim separate, effectively having two springs which means calculations can get hairy fast and I am sure I forgot some more.
    Not to say that I would not like to do it, but not currently on the roadmap.
     
    AlanMattano likes this.
  39. Zac-Yeates

    Zac-Yeates

    Joined:
    Jan 23, 2015
    Posts:
    20
    I bought this a couple of days ago and so far I'm impressed. I've got a question about camber and run time adjustments of camber. From what I've gathered camber is controlled by suspension travel and there is no way to set a custom camber amount through a script at runtime, is this correct? The reason I ask is because whilst adjusting camber based on suspension travel is correct for independent suspension, I'd like to simulate solid axles, where the camber of one wheel is dependent on the suspension travel of the opposite wheel
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Camber can be adjusted through the script at the runtime, it is a bit of a workaround but simply do:

    camberAtTop = camberAtBottom = yourCamberAngle;

    And that will do it. Of course, if you do it like this you will need to calculate "yourCamberAngle" by yourself - which is what you are trying to do if I am correct. You could calculate the value from spring compression, e.g.:

    float x = leftWheel.spring.compressionPercent - rightWheel.spring.compressionPercent;
    leftWheel.camberAtTop = leftWheel.camberAtBottom = -maxCamber * x;
    rightWheel.camberAtTop = rightWheel.camberAtBottom = maxCamber * x;

    I am writing this off the top of my head so syntax might not be accurate, but it should work somewhere along this lines.
     
  41. Zac-Yeates

    Zac-Yeates

    Joined:
    Jan 23, 2015
    Posts:
    20
    This may seem like a stupid question, but how can I set a WheelController as a variable in UnityScript? With the inbuilt wheel colliders all I need is this
    var LeftWheel : WheelCollider;
    What is the equivalent to this for the Wheel Controllers?
     
  42. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    WheelController is a script, so you use it as any other script.

    var wc : WheelController;
    wc = someGameObject.GetComponent("WheelController");
     
  43. Zac-Yeates

    Zac-Yeates

    Joined:
    Jan 23, 2015
    Posts:
    20
    Strange, that is how what I tried and it gave me an error. I'll try again tomorrow and if it doesn't work I'll PM you with more details
     
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    v1.8 has been submitted for review and will be out in a few days.
    Changes:
    - Reworked editor that now works properly when multi-editing objects.
    - Greatly reduced sideways creep on angled surfaces (not eliminated).
    - Fixed bugs when creating a new WheelController from script.
    - Changed wheel inertia to not be dependent on rim size (only tire size).
     
  45. GillesVermeulen

    GillesVermeulen

    Joined:
    Dec 23, 2013
    Posts:
    3
    Hi. Has there been any work or progress on support for "curved tractive surfaces" (as mentioned in a post in August)? Or could you advise on how to get started to implement it? Thanks!
     
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    Hello. If you need to use WC3D for a motorcycle you can do it by setting the side-by-side resolution to 1, meaning the WC3D whill have the shape of a disc. This is enough for most motorcycles since their wheels are usually not wide enough to matter. As for the curved collider I have implemented it as a POC and in the end decided that it would not be added as there would be some performance loss and greatly increased complexity. There were some changes through the last few versions to make it work better with a motorcycle and three people that I know of have successfully implemented it, one of which left a review on the asset page.

    TLDR; It works with motorcycles fine as it is, as long as you do not have a extremely wide round tire.
     
    GillesVermeulen likes this.
  47. GillesVermeulen

    GillesVermeulen

    Joined:
    Dec 23, 2013
    Posts:
    3
    Appreciate the info. I'll try it out!
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    If you encounter any problems do send me and email and I will help out.
     
  49. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    @NWHCoding If i want to use this plugin with other physics plugin as Realistic Car Controller that using Unity build in Wheel Collider (drift function..etc), so is it possible ? Thanks.
     
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,692
    It can be done as this video demonstrates: https://www.youtube.com/watch?v=oYOToeZwg6k
    In the video above one of the customers implemented it with RCC.
    Note that I however have not tried it and cannot tell you how much time that might take, as I do not own the package.
    I do not give out support for packages that aren't mine, but will help if you decide to implement it and need help at some point.
     
Thread Status:
Not open for further replies.