Search Unity

Universal Wheel Physics

Discussion in 'Assets and Asset Store' started by Roni92pl, Jul 29, 2015.

  1. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    We're finally here! :D

    Universal Wheel Physics, is raycast-based wheel behaviour solution alternative to standard Unity's wheel collider(WC). It is more stable, flexible and easier to use. You're not limited to use it as car's wheels. It can be almost everything: Plane's wheels, tank's wheels, or even you fancy robot that have wheels on its arms, head, use wheels anywhere you need! You're also not limited to use it rotated towards -Y axis like you are with standard WC. To make it as flexible as possible, it also doesn't solve steering internally, instead you just rotate your wheel's transform, so your vehicle's steering is natural consequence of changing direction of forces, not some fake-internal calculations.

    Features:
    -raycast-based
    -well optimized, fully C# coded
    -very similiar to Unity's inspector/API
    -mobile friendly
    -flexible: exposed as many options as could,while reamining simplicity of configuration
    -automatic handling of visual wheel's rotation and positioning
    -much more reliable and universal than standard Unity's WC
    -mixing of forward/sideway forces
    -finally you can have wheels on your vehicle's roof and sides!
    -suspension forces affect other rigidbodies
    -simulation of wheel's rotational inertia(you can adjust cars angle in air by accelerating/braking)
    -uses realistic Pacejka's wheel friction curves(fully adjustable on the fly)
    -friction curves updates automatically after every change to their variables
    -smoothing of visual wheel movement(no more up and down wheel teleporting on square obstacles!)

    Asset store: https://www.assetstore.unity3d.com/en/#!/content/41456
    WebPlayer demo: CLICK
    Have fun, post your opinion or feature request, all feedback is welcome! ;)
     
    Last edited: Sep 26, 2015
  2. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    I hope you will upload a webplayer to test it before buy it.
     
  3. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Customer wish is my command;)
    WP will be up this weekend at the latest.
     
  4. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Waiting for this !!.

    And if i want to make a drift car, can use this to make drift car ? is it optimized for mobile ?
     
  5. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Yes, drifting game should be no problem, also UWP's performance is mobile-friendly.
    I should mention it in main description, thanks for reminder.
     
  6. emergki

    emergki

    Joined:
    Oct 15, 2007
    Posts:
    422
    Yes, demo will be great :)
     
  7. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Web player demo is ready!
    Updated first post.
     
    emergki likes this.
  8. invadererik

    invadererik

    Joined:
    Oct 31, 2010
    Posts:
    148
    So bought it, tried to make a motorcycle, bike falls to the side with 2 wheels. OK, fine tried 4 wheels, wheels are somewhat close together and only 2 visible wheels. Really hard to turn for some reason, and still falls to the side too easily. Could you maybe make a motorcycle example ?
     
  9. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Of course bike will fall on it's side, it's not complete vehicle physics solution, its 'only' wheel collider :) ( for 2-wheeler you would need fake gyroscope-like forces, but it should't be hard, for start I would recommend applying torque force in your bike's Z axis opposite to leaning ).
    Regarding 4-wheeler - did you setup everything as in example scene? If you don't succeed with example scene, try doing step by step instruction in manual, I explained there how to setup wheels so they will position and rotate properly.
    If you will still have problem with visual wheels, send me your project(vehicle on empty scene), and I'll check what's the problem.
    But it really isn't anything fancy you just have to set your's visual wheel transform, so that it's axis is aligned with X axis, and pivot is in it's center. Let me know if you succeed with it ;)
     
    Last edited: Jul 31, 2015
  10. emergki

    emergki

    Joined:
    Oct 15, 2007
    Posts:
    422
    One question, in your wheel physics, do you add Torque for Acceleration and Brake like Wheel Collider or, it can be made in another way?
     
  11. psychicparrot

    psychicparrot

    Joined:
    Dec 10, 2007
    Posts:
    884
    Hi Roni,
    This looks really good! Is the demo car rig included? :D
     
  12. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    I don't know if I understood your question, but yes, it uses addTorque on acc/braking for simulating rotational inertia.
    Yes, of course ;)
     
  13. imaleper

    imaleper

    Joined:
    Nov 14, 2012
    Posts:
    30
    Hello,

    How can I check if the wheel is grounded? Like stock WheelCollider.isGrounded

    Thanks
     
  14. ZJP

    ZJP

    Joined:
    Jan 22, 2010
    Posts:
    2,649
    Pretty sure this tools has an equivalent. ;)
     
  15. imaleper

    imaleper

    Joined:
    Nov 14, 2012
    Posts:
    30
    Oh ye? Well what is it then? I bought it and I cannot find the equivalent
     
  16. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Yes, it's my little oversight - there is "contact" variable, but it's private. Fix is on way. In the meantime you can fix it by yourself just by changing contact variable to public in UniversalWheel.cs class. It should work exactly like Unity's isGrounded.
     
    ZJP likes this.
  17. emergki

    emergki

    Joined:
    Oct 15, 2007
    Posts:
    422
    @Roni92pl , is possible to have a "big" torque without having "big" speed?, like a Truck for example, that have big torque to move the high loads and with very low speed.
     
  18. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Sure. Just limit torque when your target rotational velocity is reached.
     
  19. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi @Roni92pl

    I can not play webplayer via your website (not problem of using Chrome). Could you upload the latest version of webplayer build into dropbox or something other host, so i can download it ?

    Thanks
     
  20. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Hello, we got some small update! The most important change is that fluent wheel movement system is no beta feature anymore, as it works perfectly now. Changelog:
    v1.1:
    UniversalWheel class:
    -new property: SidewaySlip and ForwardSlip (read only)
    -new property: HasContact (read only)
    -new function: GetGroundHit
    -feature: fluent wheel movement system 'lag' fixed
    -general little cleanup of code and comments
     
  21. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
    Hmmm... I don't get it. Can you describe in few words - why this asset better than wheel collider? o_O
     
  22. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Prodigga likes this.
  23. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
  24. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Sorry, no other version is planned. But there you have WebPlayer demo where you can try its behaviour.
     
  25. Vossyy

    Vossyy

    Joined:
    Jul 15, 2015
    Posts:
    11
    Hey Roni92pl. Great work on the wheel physics.
    I´m interested in buying, but i heard that these physics are very unstable for bikes/2 wheeled vehicles. I would like to know if they can be adjusted to work with 2 wheels. Maybe removing the Suspension code all together would help, because for my bike physics game, it is not needed at all. If you help me figure this out, im gonna buy your asset. Thanks and waiting for your reply.
     
    Last edited: Oct 6, 2015
  26. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Hey Vossyy, it so happens that few days ago I helped one folk with just the same issue(or very similiar?). It was 2d bike platformer, and we managed to have almost "non suspension" behaviour on his bike, just by setting very stiff suspension. So, yeah basically its feasible, just keep in mind it won't be 100% non movable wheels, they will always move a little on jumps and bumps. But again, you can lock your visual wheels to not move and you can have pretty convincing effect, and a little movement of physical wheel can be interpreted as tyre compression then ;)
     
  27. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Hi, do you think is possible to extend your script to support multiple raycasting (at different angles) and collision points on each wheel?
    The main reason is to avoid a wheel to enter inside an irregular terrain or inside a wall and, at the same time, apply the correct forces based on the hitting points and hit normals.
    Also would be even better if the suspension could have a two dimensional range limit instead of just a line.
    Thanks.
     
  28. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    I dont think many raycasts would be a good solution for that case. I was working on wheel with real physicall shape( cylidner) with slip-based friction instead of raycasts. The problem was that you can't calculate contact force, because there is no any compression, like in raycast. I mean, you can calculate force of hitting wheel to the ground, but what when it is already touching it? There was no way of getting this force when I was working on it.
    They added recently this - http://docs.unity3d.com/ScriptReference/Collision-impulse.html
    So I guess it's maybe feasible now.
     
  29. radimoto

    radimoto

    Joined:
    Aug 23, 2012
    Posts:
    257
    Hi there, is there any chance you can add a smooth follow camera to the webplayer demo? I really can't evaluate it properly with the current camera setup that is fully locked to the car.
     
  30. mcmorry

    mcmorry

    Joined:
    Dec 2, 2012
    Posts:
    580
    Thank you. I sent you a private message.
     
  31. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    I would also like to see a couple more camera options, a look at and a free camera so can better judge the physics. Is it also possible to make it easier to do drifting and doughnuts?
     
  32. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
  33. ZoneOfTanks

    ZoneOfTanks

    Joined:
    Aug 10, 2014
    Posts:
    128
    Hmmm... it seems like this thread is not so active... I just don't want to lose 20$ ;)
    Is this asset good for complex tank suspension?
     
  34. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Hi, I dont know how you want to solve this suspension, so it's hard to answer. It's generally raycast with addForce affecting rigidbody you select. So it's more of question what YOU can do with it ;)
     
  35. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    Any chance of an updated webplayer with different cameras?
     
  36. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    318
    Is the demo down? EDIT: Apparently the demo works in Firefox on Windows, but for some reason, the link redirects me to http://www.ronisvision.com in Safari on OS X.

    One thing I am looking for is the ability to lock wheels together as if they are on a single axle. Does your solution support this?
     
    Last edited: Dec 1, 2015
  37. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Hmm, good question. The answer is yes, and no. Yes, because you can attach it to axle that has its own rigidbody and it will work, but no, because you can't "remove" suspension calculations-wheels will just have suspension working relative to your axle instead of main vehicle's rigidbody. But I do custom physics solutions, pm me if you are interested.
     
  38. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    318
    I think there may be some confusion about what I am looking for. When I say lock the wheels together as if they were on a single axle, I am referring to the rotational velocity of the wheel, not the suspension. So the wheels are always spinning the same speed when the "differential" is locked, and when it is unlocked, they can rotate independently.

    I actually want the suspension to work independently, so that is good. :)
     
  39. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Hmm, I see what you mean now. There is no any engine/drivetrain logic implemented, it's replacement for Unity's wheel collider, and have very similiar functionality, that you can use to create drivetrain, engine systems etc(by using torque/brake forces on wheel).
     
  40. Bogdan-Miryuk

    Bogdan-Miryuk

    Joined:
    Nov 30, 2015
    Posts:
    1
    Hi.
    I bought your Assist, and the question of how to make a car with four-wheel drive?
     
  41. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Use axisTorque to apply torque on four wheels. Check manual to see api.
     
  42. Reaven99

    Reaven99

    Joined:
    Oct 3, 2015
    Posts:
    39
    Hello,

    I also have a question.
    First of all i am happy with your asset!
    But i am having a little trouble with it, i have a "Car" with 4 wheels attached and it is all working as it should.
    But once the car is flipped upsidedown the wheels go into the ground.
    I thought i ask here before i alter any of the code too much, i saw that the raycast is Always casting "transform.up".
    Is there a way to make it raycast all sides without loosing too much performance?

    The wheels also jump into the air once you drive onto an obstacle lets say a small cube. is there a fix for this aswell?

    Regards
     
  43. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Hi, sent you pm.
     
  44. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,056
    I would also like to see a couple more camera options, a look at and a free camera so can better judge the physics. Is it also possible to make it easier to do drifting and doughnuts?
     
  45. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    You would need to apply some external force, I guess, or manipulate wheels friction when need to drift.
     
  46. sathya

    sathya

    Joined:
    Jul 30, 2012
    Posts:
    297
    Can we use this wheel with other car physics engine ?. Say Realistic Car Controller or Edy's Car Physics.
     
  47. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    I don't see the point, but yeah, integration shouldn't be hard, and definitely feasible.
     
  48. langem

    langem

    Joined:
    Mar 18, 2013
    Posts:
    73
    Hi Roni,

    thanks for you asset. I recently bought it and it works great! Now I want my car to move on a moving platform. But it seems that your WheelCollider doesn't take the ground velocity into account and the plattform slips away under the car. Any ideas how to implement it? Thanks in advance!
     
  49. Roni92pl

    Roni92pl

    Joined:
    Jun 2, 2015
    Posts:
    396
    Yes, I had such feature in plans, but sadly due to lack of time I had to abandon it.
     
  50. Moses Joshua

    Moses Joshua

    Joined:
    Mar 27, 2016
    Posts:
    1
    What do you mean in this step, I know, I'm kinda dumb, I dont even understand the instructions (such a noob) but may you answer me?
    -Drag your vehicle's root to rigidbody field of UW, to assign our vehicle's rigidbody
     
    Last edited: Apr 1, 2016