Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our 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,683
    Hello and sorry for not replying earlier - please check post #645 in this thread.

    The stall feature has not been implemented and the clutch at the moment is there mostly as an effect. It is not your bad at all.
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Will investigate this. Any more details on reproducing it? If I understood correctly the sound still loops when you slide from e.g. asphalt to grass and stop there (e.g. sideways)?
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    1.9.3 is on the way with the following changes (expect it as soon as it gets approved, most likely tomorrow).
    • Added vehicle auto-setup script.
    • Major improvements to collision detection.
    • Added vehicle collision event.
    • Added sub-material index option to vehicle lights.
    • Added per-gear throttle limiting to make low geared, high power vehicles easier to drive using binary input.
    • Added adjustable auto brake velocity on reverse direction.
    • Added tracked vehicle turn speed limit.
    • Fix GC on WC3D.
    1.9.4 will follow soon after with the changes and fixes for the bug reports above of which I was not aware because #645.
    Otherwise it would all be bundled in 1.9.3 which has already been submitted.
     
    Last edited: Jul 4, 2019
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    You will need to upgrade Unity to 2018.3 or newer to be able to download 1.9.x.
     
  5. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Glad you're back..to this thread that is .. any cool updates coming? Mirror support? :D
     
  6. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    Check this, several times in video with slightly different conditions http://images.bzucko.sk/NWHvehicleSoundBug.mp4
     
    NWHCoding and DeathRace26 like this.
  7. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    HI,

    Just want to let you know the latest version from the store isn't working with unity 2019.1.7f1. I copied the project setting files where they should go but I have load of CS1644 errors.

    Assets/VehiclePhysics/Scripts/Vehicle/VehicleController.cs(107,17): error CS1644: Feature `expression bodied members' cannot be used because it is not part of the C# 4.0 language specification

    Thanks.
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Yes, it is working in 2019.1 but you are using deprecated .NET 3.5 (most likely you upgraded from older version of Unity) which has been deprecated about half a year ago.
    Go to player settings and set it to 4.5 which is the current default Unity setting:

    upload_2019-7-6_23-23-52.png

    Expression bodied member is essentially:
    float MyNumber => _myNumber;
    And it was not supported in .NET 3.5 Equivalent.
     
  9. netpost

    netpost

    Joined:
    May 6, 2018
    Posts:
    388
    Hi and thank you for the quick reply!

    This solved the problem. I don't know why but somehow my .NET was changed. :)

    The only error I see now is the one below but If I ignore it, I can still hit play.

    Thanks again!
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    That one appeared for me after upgrade too. I do not know why it claims it is not a valid name but probably something to do with upgrade process. Usually it goes away after opening and closing Unity.
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Work on 1.9.4 will start on this Friday. I will look to address all the issues mentioned here and the bug reports that I got through email, along with some feature requests (such as event integration). Expect the update to be out in ~<10 days from now.
     
    DeathRace26 and lynx89_ like this.
  12. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    104
    Excellent! Will FFB be one of the feature requests?
     
  13. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    NWH Vehicle is really great because it provides the best vehicle physics that is realistic but it's also the heaviest.
    I would like an option to dial between simple to full, like LOD so that we can have as many vehicles possible for the AI traffic.
    A use case is that if you drive one of the traffic vehicles, it will use full physics, otherwise, the traffic vehicle will use simple physics. The traffic vehicle may have different levels of physics depends on the view distances.
    I asked about this feature while ago and I believe you also liked.
    Please let me know if it can be supported.
    Thanks.
     
  14. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Could be somehow possible to adjust center of wheel's rotation when editing collision? It always adjusts to center of it.
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    I guess you want to wheel to go out of center? There are two ways:
    - Parent the actual wheel to the empty game object and set the empty game object as the wheel. If you want the wheel to be off center move the child (the actual wheel) using localPosition.
    - Move the vertices (slow)
    Now, this will visually move the wheel but will not affect the behavior (i.e the car will not go up and down).
     
  16. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,533
    Mirror support coming? I asked before, and I'll ask again, it's practically unet2 anyway at this point .. really and not sure why it wasn't supported in the first place when the poll came up.. photon pfff
     
    NWHCoding and Willbkool_FPCS like this.
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    It was because the Proton won by getting almost double the votes. Will try to cram it in the upcoming large update.

    Also, there will be 1.9.4 tomorrow during the day due to the bug that was introduced in 1.9.3 and that would apply throttle limiting not matter if "Enable Throttle Limiting" is ticked or not.
     
  18. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Thanks for the response!
    Also, can we get an option to choose specific particle effect for each ground entity? Now there is just smoke. I would like to make mud, grass snow and many others.. I think i could do it myself, but i dont really want to mess with original stuff cause there are updates coming and that would cause mess. Just adding ability to place prefab, that gets applied to each wheel when game is started.
     
  19. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Also, something to report. It seems like the ignore tags for damage dont work. I tried to add tag NODAMAGE for wheel mesh and added it in ignore tags but it still gets damaged. Even tried to attach it to sub Wheel controller colliders..
     
    NWHCoding likes this.
  20. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    I just got massive earrape while playing. I'm using 2 audioMixers and i dont know if i can combine these together. This came out from error loger:
    Attempt to set pitch to infinite value from script ignored!
    UnityEngine.AudioSource:set_pitch()
    NWH.VehiclePhysics.EngineIdleSoundComponent:Update() (at Assets/VehiclePhysics/Scripts/Vehicle/Sound/EngineIdleComponent.cs:68)
    NWH.VehiclePhysics.Sound:Update() (at Assets/VehiclePhysics/Scripts/Vehicle/Sound/Sound.cs:253)
    NWH.VehiclePhysics.VehicleController:LateUpdate() (at Assets/VehiclePhysics/Scripts/Vehicle/VehicleController.cs:511)
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Thank you for the report. I am working on the larger update at the moment and all the info helps. It is impossible to catch all the bugs by myself in the testing so such reports are greatly appreciated!
     
    DeathRace26 likes this.
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    The upcoming update will be 2.0 and will bring some of the long-needed changes, along with a list of bug fixes and improvements.

    Here is the new inspector with live preview for the FrictionPreset system that just got a move to ScriptableObject:
    upload_2019-7-13_16-42-38.png
     
  23. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Nice! Can we get something like materials which can make the tire go deeper? Lik wet mud which blocks the wheels?
     
  24. GameDevAcademyy

    GameDevAcademyy

    Joined:
    Jan 11, 2019
    Posts:
    34
    You have a full tutorial for this
    ? , i want to put on my car all details, steering wheel rotation, accelerometer,etc.
     
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    There is no full tutorial video, but there is documentation covering it. I have to admit that such video would be useful and is definitely on my list.
     
  26. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Another bug i've just found. I've made a script which changes 4x4 to 2wd and backward during runtime. It appears that when you have 4x4 and press reverse + handbrake, then swith to 2wd (RWD) and release all buttons, car starts to spin itself on front axle
     
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    The upcoming update will be 2.0 and it will be quite large.
    There will be a lot of things reworked, new inspector, multiple 'smaller things', multiple bug fixes, etc.
    Still, the biggest one will be the move to modules system where everything but the core functionality will be a module.
    It has been a large problem for customers to add to the asset because things get overwritten - well, that should be fixed from 2.0 onwards. This will also be a solution to the unused modules getting updated needlessly each frame and will allow for easier addition of new modules without cluttering the main code.
    Yes, this will take a bit more time than the 10 days or so I initially mentioned and will break compatibility with previous versions to some extent but I am on it 10+ hours a day so expect it to be out reasonably soon. Still, this has been needed for quite some time and hopefully you do not mind the wait.

    Also, the editor got a bit of a refresh over the past few days:

    upload_2019-7-16_12-28-58.png
     
    farfadet46, GLID3R82, Bzuco and 4 others like this.
  28. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    104
    Looking good!
     
  29. ghiboz

    ghiboz

    Joined:
    Sep 7, 2012
    Posts:
    465
    hi @NWHCoding
    did you plan to migrate to jobs + ecs?
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    No. I have migrated DWP2 to jobs but there would be nearly no benefits with WC3D.
    Sure, if there are many vehicles in the scene there would be small performance gain, but from my experience working on a few projects using jobs there is also quite an overhead to set up the jobs, it adds quite a lot to the complexity, things like adding and removing objects at runtime either require array reallocation or the arrays need to be oversized to begin with, etc. I do not feel that a system like this would benefit much from it, if at all.
     
  31. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    I have a question regarding AI. I've created an AI controller, which simulates binary input through floats. After creating 5+ AI vehicles, framerate halfs to 30 FPS. Any possible solutions to avoid this happening? I completely disabled all skidmarks and possible sorts of effects, i would like to even disable terrain material detection but i have no clue how could i do so. AI isnt really physical priority for me, but still player should be able to crash into it/ move it.
     
  32. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    An update on the progress of 2.0.
    There has been a lot of work on the vehicle powertrain model over past few weeks and here is one of the first results of a static test. Not much to see, I know, but this time I am developing the model using synthetic tests (i.e. nothing really moves except for numbers) as this way it is way easier to measure, adjust and debug.
    The graph below was recorded in Grapher (another assset of mine) and demonstrates an actual clutch working with the new engine and the new lateral friction model. To explain what is happening in the image below:
    - White line is clutch engagement. At first it was at 0 and then the clutch was quickly engaged (white line jumps to 1).
    - Red is angular velocity of the engine. Since the throttle is pinned during the whole test it quickly spins up the engine as there is no load.
    - Green is output torque of the engine (or more accurately clutch). You can see the backlash as it dips just after the first spike.
    - Blue is slip. The wheels spin for a short time while the energy that was being stored in the engine's flywheel is spent on friction and then once that is done vehicle continues calmly accelerating (not really visible on this graph due to the quite small time window).

    upload_2019-7-22_22-51-37.png

    Why the new powertrain model? Firstly, some things (such as realistic clutch) are currently not possible no matter how much time I pour into it. Secondly, the whole feel of the vehicles, their responsiveness and realism should go up a notch.

    As for the inspector - that part has been 90% finished. Everything works, modules are functional. Everything not being core functionality is now a module; this includes flip over, speed limiter, cruise control and all other modules that were cluttering the main asset. The 10% that has not been finished is the changes that the new powertrain model will require.

    So much from me for now. Back to development.
     
  33. Bzuco

    Bzuco

    Joined:
    Sep 6, 2015
    Posts:
    56
    Did you check profiler what is causing the delay? I have also plans to create several tens of AI cars in the future, so any info regarding performance is helpful.
     
  34. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    If you are on mobile coding a custom (and very basic) vehicle system for npc vehicles to be used instead of nwh would be the wisest thing to do
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    An option to disable any functionality besides the basic ones is coming in 2.0 so if you can hang on it should do what you need. Some examples:

    Each sound component can be disabled individually or sound can be disabled in general:
    upload_2019-7-23_11-56-57.png

    Modules can be disabled without removing them (red X):
    upload_2019-7-23_11-57-23.png

    The goal is also to be able to disable and enable modules and different functions such as sound at will at runtime so that you can e.g. enable sound when other car is coming towards the player and then disable it again as it is going away.

    At the moment, in 1.9.x, I would suggest checking out in VehicleController.cs what parts of the car are disabled when it goes inactive an mimicking that. Of course, that is assuming you need all the functionality of a vehicle controller for AI cars. If not then just using the most basic vehicle controller that can steer and throttle will do.
     
    Last edited: Jul 23, 2019
    farfadet46, GLID3R82 and lynx89_ like this.
  36. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Hi, Amazing asset !

    Is there any documentation on the (beta) compatibility with Photon? Especially looking for recommendations for a networked Enter/Exit solution.

    Cheers!
     
  37. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Hello,
    there is no documentation on multiplayer except for the MULTIPLAYER_README. You would setup the car normally as per Vehicle Physics Manual and then follow the few steps there are in that readme. After that it is as with anything in Photon - upon nearing the car you would need to prompt the user for input and then if user can enter the vehicle (somebody is not already in it and other checks) you would transfer the ownership to that user.
    Enter/exit in its simplest form simply means disabling the player object and setting the car as the 'player'.
     
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    I am glad to say that stalling works great, as well as the actual starter. They are both quite physically accurate - in fact I just spent a few minutes trying to start the car that kept stalling :oops:. That, combined with a realistic clutch, should give a much better sense of realism. Of course, I will put in a few options to make things more arcade for those that do not want their cars stalling.
     
    Rotary-Heart, lynx89_ and Mixa1985 like this.
  39. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    That's an awesome feature, congrats!
     
  40. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    I don't see any MULTIPLAYER_README file in the "Vehicle Physics" folder. Am I missing something?
     
  41. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Wait... When I click on "Package Preview" on the asset store I'm seeing some photon related scenes & files. However when importing the package in Unity, it's not there. Is it a Unity version issue? I'm on 2018.2.12f1
     
  42. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Yep. 2018.3 is minimum required for version 1.9.x which means you are using now quite old 1.7.x at the moment.
     
  43. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Thanks, It'll be worth it. I'll start the painful process of breaking my game to upgrade it to 2018.3 :D
     
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    While you are at it I would suggest going for 2018.4 as it is an LTS version.
     
    Willbkool_FPCS likes this.
  45. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Good call, thanks!
     
  46. marcrem

    marcrem

    Joined:
    Oct 13, 2016
    Posts:
    340
    Thinking about doing an even more painful upgrade and change to HDRP. Will this break this asset?
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    It should not since it does not rely on any fancy shaders. You might get a glitch or two in the demo scene (e.g. water and things like that) but nothing related to the physics or functionality.
     
  48. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    Update on the progress for 2.0:
    The solver works a treat. Engine, transmission and clutch are finished. Now that the gritty part is done differentials and other powertrain / drivetrain components should be a bit faster to develop. I am hoping to have a cobbled together development preview for you in the near future (using the WC3D demo scene).
     
    Willbkool_FPCS likes this.
  49. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Please, make option to keep discrete coll detection. I use box colliders for performance purposes and when i crash into dynamic object, car tends to sink in it. Example lamp post. With discrete detection turned on during runtime, results became much better. It is better to keep discrete coll detection (in my case atleast)

    EDIT: Any possible Unity version restrictions for newest update?? I have 2018.3 so just asking if there wont be any conflict
     
    Last edited: Jul 28, 2019
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,683
    No, it will stay 2018.3. Collision detection should not matter, if it switches it by itself it is most likely a bug but there is no reason not to use any other type of collision detection.