Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Wheel Controller 3D - Customizable Three Dimensional Alternative to WheelCollider

Discussion in 'Assets and Asset Store' started by NWHCoding, Nov 17, 2016.

  1. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,666
    i think i found several bugs with the initialization code. I need to create the collider from script, so I did this

    WheelController col = go.AddComponent<WheelController>();
    col.useRimCollider= false;
    col.autoSetupLayerMask= false;
    col.LayerMask = MyGameManager.layerTerrain;

    then, i go into the editor, hit play and although "use rim collider" is disabled, the rim collider is there and it was created, provoking collisions.

    Also, my layermask is set to nothing. It's empty. It seems to empty it for whatever reason.

    Lastly, my rigidbody flies into the air. It seems it doesn't like to be created from script.
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    I will soon be posting a major update soon that removes raycasting and the rim collider.
    So if it is not a too large issue would it be a problem to wait for the update?

    The NVP2 is creating the WheelController from script in the VehicleSetupWizard, I can PM you that if you would like to compare with your code.
    Also, the useRimCollider sounds like it might be a bug, but I am not sure why because when unticked in the editor it works.
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    That definitely does not look right (the bouncing). What is the mass of your vehicle?
    Also, it would be best if you could PM me the prefab.
    And lastly please consider joining the discord or contacting me over email as forum notifications are not the most reliable.
     
    KutluKan likes this.
  4. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,666
    Depends, when would the update be ready?
    Also, what’s your discord channel?
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Found the issue.
    The WheelController transforms were scaled to [0.3,0.3,0.3] and the wheelchair Rigidbody to [0,75, 0.75, 0.75]. WheelController must have scale of [1,1,1] and Rigidbody transform should also have the [1,1,1] scale.
    The visual object can be scaled to any scale, however.
    To scale the wheelchair select the model in the Project tab, go to the model import settings and set the scale there. Alternatively it can be done in the 3D software but the result is the same.
    I will add warnings to the next update to warn users of the scaling.
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Confirmed this. The option only works if set from the editor.
    A fix for this would be to replace the line 177 in the WheelController.cs with
    public bool useRimCollider = false;
    . Just a temporary patch until I release the update as the option is going away anyways.

    Both the Discord and email are in the signature.
     
  7. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,666
    The problem was not only the rim, also some other settings.
    col.autoSetupLayerMask= false;
    col.LayerMask = my layer mask here;

    for instance will be gone when you set those in runtime.

    You said you are working on a system without raycast. When would that be available?
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Interesting, it seems like the values are not being applied, which is weird because I am not changing them during initialization.

    I do not have specific ETAs as I am taking my time to do everything properly and do all the testing needed. However, it is already in usable state, but needs integration with NVP2, testing, docs changes, etc.
     
  9. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,666
    any chances we get some beta access? I'm not using NVP2 at the moment for this project, only the wheel controller and you managed to remove raycast it would be nice to have a look
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Hello, I would suggest joining Discord in the signature below for more frequent updates (and there have been many).
    Beta is out of the question at the moment since some improvements are still needed and Asset Store does not have a good way of doing betas officially. It might come bundled into the asset as a package that needs to be imported as a way of beta.
     
  11. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,666
    i joined the discord and asked the same question just to be told that no beta available in any format... it would be nice to have some beta access so that we can test and help for the next release
     
  12. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Correct, there is no beta available since the new update is not ready. I consider beta a completely finished update with all the features and testing done, but still needs customer testing in different scenarios, platforms, etc.
    So once I weed out the issues and bugs I will be publishing it included into the asset (WC3D and NVP2) as a package that can be extracted for testing.
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Another update on the beta.
    As some of you that are active on the Discord channel might now (link in the signature), the WheelController3D just got a major rewrite.
    Most notable changes:
    • No more Raycasting / layer setup.
    • Major performance improvements.
    • Completely new ground detection resulting in improved handling.
    • Code and API cleanup.
    • New tabbed inspector.
    • Improved low speed friction with no creep.
    • NRigidbody / substepping no longer required (performance improvement).
    • IWheelUAPI - interface that allows for in-place switching between WC3D and WheelCollider.
    • And much more. Complete changelog will be available on release.
    Beta will ship in parallel to the current version, and will replace it when it is stable enough.


    A few screenshots:
    upload_2023-1-27_21-41-6.png



    upload_2023-1-27_21-41-46.png
     
    Last edited: Jan 28, 2023
  14. StudioTatsu

    StudioTatsu

    Joined:
    Dec 31, 2018
    Posts:
    10
  15. PavelFoxx

    PavelFoxx

    Joined:
    Nov 14, 2016
    Posts:
    12
    I need to have ability to do barrel rolls with car (more casual driving). But car is rotating back on wheel while in the air. I have set "Anti-roll" to 0. Commented "ApplyAntirollBar" method, but it does not help. What can I do?
     
  16. PavelFoxx

    PavelFoxx

    Joined:
    Nov 14, 2016
    Posts:
    12
    I'm using "WheelController3D" package
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Could you explain what kind of rotation you are getting? The only thing that could be happening is that the rotational inertia of the wheel (that is either accelerating or braking and hence has a change in angular velocity) might induce pitch up/down behaviour. The ARB does not have any effect while in air. So if you are not applying any motor/brake torque it will not have any effect on the Rigidbody while in air, and you can comment out that part too if you specifically do not want the behaviour. I believe it is under "chassis torque" on the current version of WC3D (beta incoming soon).
     
  18. PavelFoxx

    PavelFoxx

    Joined:
    Nov 14, 2016
    Posts:
    12
    Rotational inertia of the wheel was the thing. I've done that Input does not effect anything in mid air, and it works. Thank you
     
  19. PavelFoxx

    PavelFoxx

    Joined:
    Nov 14, 2016
    Posts:
    12
    How can I set speed limit? I found speed limit module for Vehicle package, but don't I have one for just Wheel Controller 3D?
     
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    The speed limiting can be done in two ways. If you want it to be a speed limit based on physics (i.e. the vehicle lacks power to go over this speed) then you can use the Rigidbody drag to approximate aerodynamic drag, or on the other hand you could artificially limit it by cutting out motorTorque over certain speed.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    10.17f

    13/03/2023
    • [WC3D] Major longitudinal friction update focusing mainly on creep on slopes and high speed / low update rate stability. No adjustment necessary.
    • [WC3D] Native friction is no longer used for creep prevention as this has been implemented inside the WC3D itself and thus no longer needed.
    • [WC3D] WheelController no longer uses ContactModifyEvent callback which results in improved performance, esp. in scenes with many colliding objects.
    • [WC3D] Added OtherBodyForceScale. A value by which the forces applied to other Rigidbodies are scaled to allow for interaction with lightweight Rigidbodies.
    • [WC3D] Fixed no-suspension friction behaviour. The friction is now the same for no-suspension/bottomed out suspension and normal suspension.
    • [WC3D] Merged “Actions” and “Advanced” tabs into a single “Misc” tab due to the only few fields remaining under the “Advanced” tab.
     
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    A new video is up:

     
  23. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,005
    Looks good. No slip-down on a slope when brakes on?
     
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    With 10.17f there is no slip/creep on any slope, as long as the surface material has enough grip. I.e. the slope angle depends on the surface material, i.e. on ice it will slip with small angles - but that is by design.
    The whole 10.17f update was mostly about rewriting the friction with the focus on no creep on slopes.
     
    andyz likes this.
  25. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,666
    This isn't using raycasts right? How are collisions detected? I would need to use this with Photon Fusion and all physics there into a FixedUpdateNetwork.
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Not raycasting, but a similar approach. A lot of tricks learned over the 7 years of this asset being out have been integrated into the recent rewrite, and the ground detection is also separated from the main code so that it can easily be changed/updated/swapped out. In regards to performance and behaviour this is currently the best approach that I know of, and I have spent weeks testing all the alternative methods. Great high speed stability, excellent performance (~0.006ms / wheel of CPU time on desktop, in Editor) and very few downsides.

    Edit: Forgot to mention that all the updates are done through FixedUpdate, so there should be very little work to convert it to a custom call. Just replace the
    _dt = Time.fixedDeltaTime;
    with whatever dt Photon Fusion is using.
     
    Last edited: Mar 15, 2023
  27. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,666
    Yeah, Photon Fusion is the new way to go instead of PUN (deprecated soon).
    Basically, if you want to give it a try yourself, all physics are done in a FixedUpdateNetwork (you can't use FixedUpdate) because it rolls back and resimulates collisions to detect what happened during lagged interactions. But this means that you need full access to the physics code, so you can do raycasts and all you want. You just cannot use WheelCollider for instance, because the internals of that component cannot be networked.
     
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    Understandable. WheelController3D should not have issues then as it is shipping with the full source code and does not use any exotic APIs or methods. Everything is done within FixedUpdate() so switching should be relatively straightforward. NWH Vehicle Physics 2 currently supports PUN2 and Mirror, but I am thinking of switching to Netcode for GameObjects as this is the official solution. Unfortunately, supporting many different multiplayer solutions out of the box is not possible since it is a huge time sink and this is still a one-man band :).
     
    creat327 likes this.
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    10.18f

    17/03/2023
    • [WC3D] Fixed RPM spike bug under braking.
    • [WC3D] Fixed wheel locking up too easily when both motorTorque and brakeTorque are applied.
    • [WC3D] Friction bug fixes and improvements. Improved stability at dt = 0.03 (33Hz physics update).
    • [WC3D] Fixed glitching/jumping wheel when the approached obstacle is above the axle height.
    • [WC3D] Camber is now just a single value and is not changed by the WheelController automatically. For that the CamberController script was added. Removed CamberAtTop and CamberAtBottom from WheelUAPI.
    • [WC3D] Fixed SpringCompression returning inverted value.
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,532
    10.19f

    20/03/2023

    • Performance optimization.
    • Fixed issues with starting on slopes.
    • Fixed flickering camber bug introduced in 10.17f.