Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Assets NWH Vehicle Physics

Discussion in 'Works In Progress' 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. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,435
    Looking forward to NV2, though 2 of my requests are mirror networking and motorcycle support... mmmm :) at good cough low price if its going to be addon
     
  2. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    45
    Will Version 2 be compatible with new Input System?
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    Goal is to have it compatible with old, new and Rewired.
     
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    Currently working on better trailer mechanics. The goal was to be able to attach a trailer to a trailer - among other things like moving the trailer code to a module and allowing for powered trailers.

    upload_2019-10-23_20-1-11.png
     
    Last edited: Oct 23, 2019
  5. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,435
    and yet I'd rather see mirror support built in, and it being easier to do motorbikes ... than... trailers ..it just seems so ...niche? anyway just my thoughts :)
     
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    Do not worry, both are on the way. You would be surprised as for how popular the trailers and articulated equipment are.
    I am first going through all the features that were in NVP1 and working on improving them, checking the code, etc.
    After that is solid comes new stuff.

    One of those things I have been working on is user-friendly inspector which evolved a bit further from the last update:

    upload_2019-10-24_12-43-39.png

    upload_2019-10-24_12-44-10.png

    upload_2019-10-24_12-44-40.png
     
    krou, GLID3R82, Player7 and 2 others like this.
  7. Kmeier

    Kmeier

    Joined:
    Feb 9, 2016
    Posts:
    14
    That looks fantastic! I'm super excited.

    Also. Excuse me if this has already been asked/answered, but is V2 a paid upgrade? And do we have a ballpark release estimate?
     
    digiross likes this.
  8. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,027
    Looks good.

    Q: How do you get the performance characteristics of a car?

    I need to know what the maxspeed is, for example.
     
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    V2 will be a free upgrade BUT the additional modules will be provided at a charge.
    All the functionality from V1 will be included in V2 except for the tank mechanics which will be a $10 extra - so if you are using that it will be a paid upgrade in a way. Still, those ten dollars will justify me spending more time working on specialized vehicles which most of the customers do need which will result in better modules, and yet will keep the price of the base asset the same.

    Ballpark release date is as soon as it is finished - current state is that the base stuff is done and I am from today starting work on actual improvements and new features. End of year is a hard limit, one month is very optimistic limit. Somewhere in between lays the answer.
     
    krou likes this.
  10. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,027
    Is it possible to find the pitch and yaw of the vehicle?
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    Yep, and you do not need any asset to do that and this is not specific to any asset.
    There is no such helper function built into NWH Vehicle Physics but you could always do something like this:
    https://forum.unity.com/threads/roll-pitch-and-yaw-from-quaternion.63498/
    In short - convert rotation to local and compare that to your frame of reference [0,0,0].
     
  12. thrandur

    thrandur

    Joined:
    Feb 6, 2019
    Posts:
    3
    Any hints on how I would control speed, steering and other things from code (automatic driving)?

    Also some pointers on how to make my own models similar to the cool monster truck - using Blender - or is it better to find something in the asset store?
     
  13. thrandur

    thrandur

    Joined:
    Feb 6, 2019
    Posts:
    3
    Found out how to control these things by looking at the demo project :)

    Procedure:

    Add this on top:
    using NWH.VehiclePhysics;

    Declare:
    private VehicleController vehicleController;

    Define in start:
    vehicleController = GetComponent<VehicleController>();

    And then you can change things:
    vehicleController.input.Horizontal = 0f; //straight ahead
    vehicleController.input.Vertical = 10f; //engine forwards
     
    Kmeier likes this.
  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    This is correct and sorry for not replying earlier.
    There is an explanation on how the input system works inside the manual but in short the point is that the input is set externally, so you can do things such as above. DesktopInputManager works in the same way and writing your own input manager is therefore very simple - only a few lines.

    One not tho: setting the value of Vertical to 10f will do nothing since all the float values are normalized (in this case to [-1, 1]). Just set it to one.
     
  15. thrandur

    thrandur

    Joined:
    Feb 6, 2019
    Posts:
    3
    No problem - so +1 is full throttle and -1 is backwards full throttle :)

    Do you have hints for my second question:
    Some pointers on how to make my own models similar to the cool monster truck - using Blender - or is it better to find something in the asset store?
     
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    I would suggest searching for rigged/animated models - unfortunately there are not many so the best bet would probably be rolling your own. Tutorials on working with bones in blender will be of use, even better are ones that show you how to make bones work with Unity because Blender being blender it is not that straightforward.
     
  17. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    After spending good part of the week reworking the solver for NVP2 I have finally come up with a result that gives the same accuracy as the tech demo build from two months ago but with a fraction of performance cost. In fact - the new physics calculations are faster than the ones in NVP1 while being a lot more realistic.

    In-build profiler - note that the time is for two calls of FixedUpdate() and that WheelController is now being called from the vehicle script itself so the whole vehicle is using 0.04ms per fixed update:
    upload_2019-11-8_22-0-35.png

    Even in editor this time is around ~0.1ms per fixed update. Need to do some testing of the new (3rd) solver but so far seems very promising.
    Note that this is before any optimization :D
     
    Last edited: Nov 8, 2019
    krou, xDeveloper, mthawley and 3 others like this.
  18. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    520
    Hi, while we are talking about performance, I was curious if you are going to take advantage of Burst Compiler.
    It can increase the performance several times depends on the usage but I'm pretty sure NVP will get pretty good benefits.
    Please let us know if you are going to do support it soon, hopefully before v2. I think we'll have then, the most sophisticated Vehicle engine with the fastest performance.

     
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    I am using Burst compiler with Unity Jobs system in Dynamic Water Physics asset. I have explained here before why I will not use it here. Sure - if you are planning to run 50 cars on a racetrack then sure - you would get <5% performance increase. Running one car you would actually get performance decrease due to the jobs not being free and needing to be set up, data copied to native arrays, etc. Thing is that out of total performance hit of a vehicle, only small percentage is the solver. Sounds, exhausts, wheels, effects, etc. take up much more. And since solver is not stateless you can not just put each iteration on one thread and call it a day, they need to be executed one after the other.
    With Dynamic Water Physics it makes sense since all the simulated points are individual and I have made it so all the data is stored in one place - one large array. There can be two or more thousand points and processing those can be nicely spread among threads. Here not so much.
     
  20. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    520
    Hmm.. <5% performance gain from using both jobs and Burst compile is somewhat surprising if you are using 1000s of points for buoyancy testing.
    Are you sure you turned on the Burst compiler? not just using Jobs? Jobs can run in parallel and I think you will gain some performance boots just from using Jobs alone. And Burst can also add quite a bit of boost on top of that.
    It seems bizarre and there must be something wrong. I would suggest you talk to Unity guy and see there is something obvious problems.

    And regarding NVP, I thought jobifying wheel raycast would get some performance boosts not others.
    But only the real test will show the true results.
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    Oh, you misunderstood me. I was talking about possible performance gain in NVP2. There is a huge performance gain inside Dynamic Water Physics 2.

    Also, WheelController3D already uses jobs for raycasts.
     
  22. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    520
    I see.. that's good to know. I'll be looking forward to the new version. Thanks.
     
  23. admin_unity486

    admin_unity486

    Joined:
    Oct 16, 2019
    Posts:
    5
    hey guys i was wondering how i can change the sound of the cars ?
     
  24. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    520
    Oh, btw, I noticed you are supporting PUN, and not Mirror.
    Mirror is more like the standard Unity networking framework, in my opinion, inheriting UNET legacy. I've waited for the new Unity Network Stack for a year and it will probably take another year or two until it becomes usable. Besides, you will need to convert your game into ECS in order to use it. It will limit to very few people who can take advantage of it.

    It will be really nice if you can support Mirror. Is this something you will consider?
    If not, how shall we go about syncronizing vehicles over the network?
    I think there two different kinds of approaches.

    1. Syncronize just basic vehicle parameters and simulations are done on all participating clients. This will give better looking vehicle physics but it will probably not scale in terms of performance.

    2. Each client will simulate the vehicle he is driving and send the final result such as vehicle, wheel positions. Simulations are spread over several clients and it will not be taxing on performance but syncronizing simulation quality will be determined by network quality, i.e. wheels may not contact the ground at all time.

    From what I gather, simulating every vehicle on each client will take too much CPU cycle and I would like to take #2 approach at first but you may have different opinions. If simulating 10 vehicles takes less than 5 ms, #1 approach may be possible but I'm not certain if I can keep them under 5ms.

    What kind of approach did you take for PUN and what are the results?

    Thanks.
     
    NWHCoding likes this.
  25. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    As mentioned a few posts above Mirror in on the way with NVP2. Also, current implementation of PUN does exactly that.
    Clients only run vehicle physics on their own vehicle and only the results are carried over (position, rotation, steering angle, etc.).
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    There is a 'Sound' dropdown and you will see a few different sounds such as 'Engine Idle' (which will be changed to Engine Running in the future to avoid confusion), 'Engine Start Stop', etc. Here are all the settings for all the sound, including volume, pitch, etc.
     
    admin_unity486 likes this.
  27. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    520
    Oh, I only saw some requests and indeed, it's really great news! And I really like you are sending the simulation result over the network. No need to worry about high CPU usage. ^^

    In the meantime, I'll study how you implemented PUN.

    I read ETA V2 for about a month. I assume that it will come with Mirror integration.
    Please let me know if I'm not correct.

    Thanks.
     
    Last edited: Nov 13, 2019 at 10:13 PM
    NWHCoding likes this.
  28. admin_unity486

    admin_unity486

    Joined:
    Oct 16, 2019
    Posts:
    5
    thank you i missed it yesterday and now feel like an idiot ahah
    also imm having trouble getting damage to work when i import my own car ? says its enabled
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    796
    A quick update on the progress:
    Powertrain is mostly done. Solver works nicely, results are physically accurate and I have tested a lot of scenarios and they all seem to work exactly as they should. Currently working on resolving a slight shudder at very low transmission ratios (not really a bug but more of a side-product of running solver at much higher frequency than fixed update) - but then 1:100 ratio is quite extreme and actually works very well and will make for great tanks and semis.

    Next come optimization, minor improvements and general checks on the powertrain and then I will wrap that section up.
    Next come general improvements, Mirror support, etc.
    So the update is progressing well, although I spent almost two weeks (re)working the powertrain/solver which did set back the release some. But I think the time was well worth it in the end. Will post a small development build in a few days so you can judge for yourselves.
     
    krou, Kmeier, mthawley and 3 others like this.