Search Unity

  1. The 2022.1 beta is now available for testing. To find out what's new, have a look at our 2022.1 beta blog post.
    Dismiss Notice

Assets NWH Vehicle Physics

Discussion in 'Works In Progress - Archive' started by NWHCoding, Nov 30, 2017.

?

Which networking solution do you want to see implemented?

Poll closed Jan 20, 2019.
  1. UNet - Unity Networking, getting deprecated sometime in the future

    1 vote(s)
    4.8%
  2. Mirror - Community replacement for UNet (https://github.com/vis2k/Mirror)

    6 vote(s)
    28.6%
  3. Photon

    12 vote(s)
    57.1%
  4. None - I will be implementing my own solution

    2 vote(s)
    9.5%
  1. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Could we know what you did and what the problem was in the end?
     
  2. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357

    Hi.

    Correction.

    The loss of FPS is negligible. I had a car in one area of the terrain and another in another area. The loss was due to the water reflectance of the AQUAS asset.

    Thanks for everything.
     
    NWHCoding likes this.
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Great, it got me worried since I have spent quite a lot of time optimizing and looking at the profiler but in the end I could have overlooked some scenario. Glad you managed to solve it.
     
    Barritico likes this.
  4. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357
    I explain. Although in English I do not know if it will be understood well.

    The code that I introduced, worked by "chance". It coincided like that. This morning, it did not work anymore and I started to investigate.

    Indeed, it is a problem generated by using CTS. When you execute the scene, CTS generates a copy of TERRAIN DATA that DOES NOT CONTAIN any texture. I do not know the reason (I'm not going to investigate) but that's the way it is.

    If I deactivate CTS, the code works correctly. I tried to disable it so that the variables load well and then activate it again, but I must do it at run time and the textures do not fit.

    The problem is that I have everything based on CTS and I can not modify it.

    I do not know if you can contact the author of CTS to see how it could be solved. I think both assets are the most used in the market and their integration would be interesting.

    Meanwhile, I have (unfortunately) to go back to Eddy.

    Thanks a lot for everything.

    EDIT

    Effectively, the copy of TERRAIN DATA that CTS does does not contain the SPLATS.

    I solved it by collecting the data of the variables BEFORE making that copy (within the CTS script)

    I hope that helps. Thank you.
     
    Last edited: Apr 18, 2018
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    I will contact the author and see what can be done but if CTS has some kind of texture querying API this should not be a problem - unfortunately the author did not decide to make such API (if it exists) available online so I will have to wait for the response or purchase the package myself and check what can be done. Sorry for the complications.
     
  6. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357

    No problem. It is impossible to control all the variables of all the assets.
    If you get more problems in this regard, then there is a temporary solution.

    I think the work is excellent. I come from RFACTOR 2 and this asset is great.

    I have car configuration problems. For example, the SEDAN at 100 km / h by asphalt (tarmac dry) moves a lot with a slight touch of steering wheel. It has a very real, but excessive gliding.

    I'm trying to set some physics for Rally cars. It's costing me a lot of time and tests. I do not get oversteer when it enters the curve.

    As a suggestion (when you have time) you could explain a little more widely the incidence of the parameters in the behavior of the vehicles. ;-)

    Great job. Congratulations.
     
  7. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    I have to strongly agree on the fact that I owe everybody a more detailed guide on getting the vehicle handling right. Everything can be adjusted but I always wrongly assume that everyone has read a book or two on the topic and extensively reviewed the code (which of course they have not and there should be no need to) - I guess programmers can be like that.
     
    overthere, recon0303 and Barritico like this.
  8. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357
    Hi.

    Can you help me set up a car to do drift?
    I do not get it even with the hand brake.

    The braking is very "straight" and that prevents control the car to enter the curve "rally style".

    Thank you very much for your help.

    EDIT

    Solved. Thanks.
     
    Last edited: Apr 20, 2018
  9. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357
    Hello again.

    I have a problem that is important. After designing the COLLIDER of the wheels and having everything configured, the vehicle moves correctly.

    ... however, that configuration is lost randomly and the "SCAN IGNORE LAYER" parameter loses the values. It is set to "mixed" by selecting different values.

    I re-apply the parameter, but the vehicle no longer moves. The steering (left and right) does work properly but the accelerator and brake do not work.

    The only solution is to recreate all the collider wheels and that is a serious problem.

    Thanks.

    ****************

    EDIT

    The sound that the car emits, when the scene starts, is of "sliding" and in the telemetry the four wheels come out with positive RPM.

    In vehicles, when they work correctly, the value is ZERO.

    I attach two screens. Car OK and car NOT OK.

    yesOk.jpg notOk.jpg
     
    Last edited: Apr 20, 2018
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Are we talking about the parameter being lost when entering play mode or during play mode?
    Note that the selector for choosing the layers actually gets inverted in WheelController.Start() when generating bitmask since the raycast function does not allow for "ignore bitmask" but rather "hit bitmask", so if you reapply the ignore layer options during the runtime they will not be applied.
     
  11. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357
    The sound that the car emits, when the scene starts, is of "sliding" and in the telemetry the four wheels come out with positive RPM.

    In vehicles, when they work correctly, the value is ZERO.

    I attach two screens. Car OK and car NOT OK.

    View attachment 275510 View attachment 275511
     
  12. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357
    More about #210

    If I do a "copy-paste" of the VEHICLE CONTROLLER parameters of a demo car (SEDAN), it works again. I have to change the components for the correct ones (steering wheel, axes, etc) and it works.

    Then I have to adjust them to the data I want for my vehicle. All right.

    But there is a moment (I do not know when) that they get lost. I make changes of cameras, I put flags in the circuit, trees ... and, I do not know at what moment, they get lost.
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    In which way lost? Are we still talking about the ignore layer field?
    I must say that this is the first report of this kind so far. Could it be that something outside is causing it?
    Any value that is changed in the inspector will stay that way (except if in play mode of course). I just checked and changed the settings inside WC3D inpector, went into the play mode, exited and they are still there as I set them.
     
  14. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357
    Hi.

    I guess the asset is not ready 100% for the use of steering wheel

    Will there be any update on this?

    Thank you.
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Hello again.
    Yes, steering wheel is 100% supported. Even the H pattern shifter will work with correct mapping.
    Some Logitech wheels do require a single option change in the settings: https://forum.unity.com/threads/released-nwh-vehicle-physics.506909/page-4#post-3430506
    So far at least 3 users and myself have used it with a wheel (Logitech Driving Force Pro, Logitech G27 and Logitech G29). Did you encounter any problems?
     
    recon0303 likes this.
  16. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357

    Thanks for your quick response.

    The problem I have is that the use of the combined axis does not seem like a good option for a sports driving game. Many times it is very necessary to use the brake and the accelerator at the same time and with the combined axis is not possible.

    Unless it is my mistake, when you step on the pedal the car accelerates and when you release the car brakes with what never happens a "deceleration" due to inertia.

    In addition, the range goes from -1 (without using it) to 1 (used to maximum) with what in the "negative" zone (from -1 to 0) there is no acceleration because they are negative numbers.

    But I may be doing it wrong.

    Thanks again for everything.
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    I would suggest checking the link in the previous message to the post that had about the same question.
    You will need to set the pedals as "Combined" in Logitech settings (I am assuming) and then you will not have the problem any more.
     
  18. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    357
    Yes. I have already checked the link.
    I will try to find another solution.
    Thank you.
     
  19. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    366
  20. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Would you be so kind as the share how you reproduced those bugs so that they can be fixed?
    Some of them are not bugs tho - such as the red car bottoming out and getting stuck on the corner is from it being low to the ground.
    - Unfortunately small sideways creep on tiled surfaces is a known problem and is very hard to fix due to the slip force being calculated as reactive force, and being that the fixed update happens only so often. A too small reactio results in creep while a too high one results in jittery vehicle. I will work on this some more tho.
    - Tank is known to be the most bug prone since it was added last, as an addon. It would be great if you could write what you did to make it flip like that, and what settings have been used.
    - Some vehicles jumping when getting near to each other happens because I set them all at the same layer so they get detected as ground themselves (actually there are two layers, one for 8x8 and monstertruck and other for the rest of the vehicles).

    I hope to have most of those eliminated by the end of the week.
     
  21. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    366
    I just drove the vehicle over obstacles.

     
  22. Justin_Wingfall

    Justin_Wingfall

    Joined:
    May 15, 2014
    Posts:
    125
    hmmm, still no word from RGT developer or if this is going to be compatible?
     
  23. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    We got in touch. He is working on version 2.0 which will have compatibility with this package.
     
    GLID3R82 and Justin_Wingfall like this.
  24. obstudio

    obstudio

    Joined:
    Sep 30, 2016
    Posts:
    58
    Hi, it's pretty easy to reproduce Tank issue on 2017.4 - just drive tank on the wood.
    BTW: think about option in "flip over" like manual/auto, so user will be prompted with key press for flip manualy (like entering vehicle)
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Nice idea.
    Maybe I should not have tried to cram a tracked vehicle into a dedicated wheel-based solution...
    I have a few ideas on how to solve that problem and a few more tank-related problems tho.
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    New update will be pushed to the store at the end of the week.

    Here are the changes so far:
    • Fixed RPM being off on the RPM gauge inside the demo scene.
    • Fixed average speed showing wrong values.
    • Remove leftover tutorial scene.
    • Add option to freeze the vehicle when inactive.
    • Make prefabs function after dragging without need for dragging input manager onto them to prevent confusion and make vehicles work ‘out of the box’.
    • Improvements to tracked vehicles as well as tracked vehicle documentation.
    • Vehicles with larger wheels sometimes hesitate when changing from reverse to first gear.
     
    GLID3R82 and Rotary-Heart like this.
  27. SilverSho0t

    SilverSho0t

    Joined:
    May 10, 2013
    Posts:
    15
    Hello, the bug mentioned by Marcos-Schultz can happen on all vehicles, when they collide with other collider or rigidbody they can make a jump in the sky and start making wtf things indefinitely.

    It's like there is a force applied to it, where we don't need it.
     
  28. SilverSho0t

    SilverSho0t

    Joined:
    May 10, 2013
    Posts:
    15
    A video about this bug :

    I seem that it happens when another collider enters inside the wheel collider, what should not happen ?
    Bug.jpg
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    WC3D works on the basis of raycast as that is the only viable solution at this point in Unity (no, sphere collider will not work and sweep test does not have ignore layer option and it still works based on primitive shape casts in the background). So the wheel is not actually a physical thing and behaves in that matter like the default wheel collider. Now, to fix this so called rim collider was added and my suggestion is to enable it as it adds a convex mesh collider that covers the upper half of the wheel to prevent it from getting triggered from the sides it should not be. And somebody might also ask why would I not simply use a shorter raycast that checks just the bottom of the wheel area and that is mostly to do with the tick rate of fixed update being very much discreete and raycast actually possibly being shorter than the distance traveled in a single period between updates which results in ground just being ignored.
    Also, just attaching two spheres as wheels and then rotating them will not work - trust me, I tried that one first.
    Hope this explains some reasoning behind things inside WC3D.

    Edit: forgot to mention that some vehicles in the scene (like that semi) do not use rim collider and that is the reason you got the jumping semi. I will tick this option in the upcoming update for all vehicles as a default.
     
  30. SilverSho0t

    SilverSho0t

    Joined:
    May 10, 2013
    Posts:
    15
    Thank you for your reply, I try your fix it does the trick.

    Thanks,
    Sean
     
  31. SilverSho0t

    SilverSho0t

    Joined:
    May 10, 2013
    Posts:
    15
    Hello, I have another little problem, I tried to fix it myself by it doesn't work.
    It happens when you detach the trailer. If you can help me?
    bug.png
     
  32. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    84
    Having input issues. Can't seem to actually operate any of the vehicles once they're set up. Keyboard doesn't work, neither does the xbox gamepad I have working with Edy's vehicle physics. Neither the included prefabs or my own vehicle setups work
     
  33. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    694
    Is there any way we can include Physic Material data into the calculations? Wondering if that way we could even reduce the stop slip too.
     
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Hmm, does this happen in the demo scene? Any way to reproduce the error.
    This is most likely a bug. The trailer has brakes, brake ligths, etc. - in fact it is a full fledged vehicle controller that gets its input from the truck through the input states script. It most likely still thinks that it is attached but it is confused because the truck is missing, or vice versa. Added to the TODO for the update: https://docs.google.com/document/d/1Y34iwEsQsAt-t-3OOnVvG0o6wVDT6dp2XFkYhr1M3uw/
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    No, everything that is done is done through the Wheel Controller inspector, friction curves and coefficients. The is not *actual* physics collider that will interact with the ground (nothing like sphere collider). Friction curves are fully adjustable through the WheelController.FrictionCurves.cs.
    The biggest improvement will be if you set your fixed update time to 0.015 or even 0.01, that is if you can afford it.
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Hello,
    I will have to first explain how the input on the vehicles works. I believe this is explained in the manual but let me clarify.
    If you drag the (current version) vehicle into the scene it will not move. If you just want to use that one vehicle without all the Vehicle Changer stuff you have to assign either Desktop Input Manager or Mobile Input Manager script to the vehicle, with the vehicle changer field set to non. This is because vehicles themselves do not directly communicate with input but rather just store the states in the InputStates.cs script. This was made so that outside scripts could easily be made and attached to the vehicles that toggle and set those values, so if you e.g. wanted to roll your own input manager you could attach your script and just set the values however you wanted (or you can just use the provided ones).
    The reason you need to set the vehicle changer field to None is because if it is present it will just route all the input to the currently active vehicle.

    So what you need to do is:
    - Drag the vehicle prefab into your scene
    - Attach "DesktopInputManager" to it with vehicle changer field set to None.

    And you are good to go.
     
    FargleBargle likes this.
  37. SilverSho0t

    SilverSho0t

    Joined:
    May 10, 2013
    Posts:
    15
    I'm on 2018.1.0f2. I try to reimport the asset multiple times and it does the same.
    Just launch the Island scene, take the truck, attach a trailer and detach, and it does the error here.

    + Lights of the truck are not visible when the game is built. (We can even see this bug in the demo from your link)
     
    Last edited: May 3, 2018
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    The solution to the trailer error is to remove the following code:

    trailerVC.input = null;

    At the line 231 inside TrailerHandler.cs.
    Thanks for the heads up on the error. Now let's see what is happening with the lights.
     
    Last edited: May 3, 2018
  39. SilverSho0t

    SilverSho0t

    Joined:
    May 10, 2013
    Posts:
    15
    Ok, thanks, it works, I also got lights to work. I just include Standard shader in GraphicsSettings.
    Capture.PNG
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Thank you for that, will be added to the manual.
    Now if somebody from Unity could say why Legacy Shader IS included by default and Standard one is not - that would be nice. I guess they have their reasons.
     
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Thank you for that, will be added to the manual.
    Now if somebody from Unity could say why Legacy Shader IS included by default and Standard one is not - that would be nice. I guess they have their reasons.
     
  42. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    84
    Thanks for the suggestion but I tried this and nothing is working still. I'm wondering if there are version problems with Unity? I'm using 2017.3.1f1 but I also tried it with the very newest version and it won't even let me open any of the scene because there are so many errors with NWH. In the 2017 version everything seems to work fine except I have no control. I'm trying to use an Xbox controller but keyboard doesn't work either. You should include this input setup in your tutorial videos
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Errors? Did you check the readme?
    What kinds of errors do you get?
    Also Unity version does not matter, I tested it with 2017.1 up to 2018.1 and adter doing the two steps from readme all is good so I would suggest checking it out - it is just inside the Vehicle Physics folder.
     
  44. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    366
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    It seems to be a bug when WC3D goes from a single ray mode to multi ray mode when vehicle is entered that causes the bug - most likely caused by the amount of caching and optimization. This is just a pure bug and I will look into it immediately. I should hire you as a tester, you seem to be doing the job quite well :)
     
    Last edited: May 4, 2018
    Marcos-Schultz likes this.
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    The bug has been fixed - this should also solve most 'jumping / flying into the air' problems. I will solve the rest of the bugs and then post the beta for v1.6 in here.

    There will be an included option with v1.6 called "Freeze When Still" under General dropdown that will freeze the rigidbody along X and Z axis when the velocity reaches very near zero and there is no input. It is a bit of a fix but works better than I could have imagined so it will be included into the update.
     
    Rotary-Heart likes this.
  47. thegreyman1

    thegreyman1

    Joined:
    Jun 10, 2010
    Posts:
    164
    Yeah I've followed every guide I could find in the asset as well as your suggestions here. Even in a brand new project something is wrong. Could it be in my project >input settings? Could you tell me what your settings in here are to get an xbox controller working? Like I said the controller works perfectly well for Edy's vehicle physics so I'm not sure what's wrong here
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,358
    Could you tell me what exactly is wrong? Can you drive around using keyboard for starters?
    If you get errors similar to "NameOfInput not assigned" then yes - it is input settings. I would suggest following the readme and copying the example InputSettings and then going from there. Everything is done through the standard input manager, nothing fancy - for example:

    Input.GetButtonDown("ShiftUp")
    Input.GetAxisRaw("Vertical")
    etc.

    So if you get the error that ShiftUp is not assigned you will either to have to add it to the input manager (or just copy the input settings). After that assign the wanted mappings inside the input manager. Here are xbox controller mappings:

    https://ritchielozada.com/2016/01/16/part-11-using-an-xbox-one-controller-with-unity-on-windows-10/

    So if you wanted to use triggers for shifting you would just need to assign that button in the input manager. There is no example InputSettings for xbox specifically but you can use the provided example one and instead overriding the keyboard you can set the xbox controller mappings using the Alternative Postive / Negative fields:

    https://docs.unity3d.com/Manual/class-InputManager.html

    Hope this solves your problem.
     

    Attached Files:

    overthere likes this.
  49. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    366
    You're making a lot of errors in the Inputs, I can not even play now.

    It would have to completely eliminate this dependence on the Standard Assets. In my asset I created my own FPSController to avoid such problems.

     
  50. jebalsaad

    jebalsaad

    Joined:
    Sep 7, 2016
    Posts:
    9
    Hi there:)

    Is there any plan to integrate this tool with TPs input tools like rewired .... I think by doing that the most of the input problems going to be solved and i don't think it need to much work....
     
unityunity