Search Unity

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

  2. Unity 2022.1 is now available as the latest Tech release.
    Dismiss Notice
  3. Improve your project's performance with our new guide on profiling in Unity.
    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. kjiforouter

    kjiforouter

    Joined:
    Jul 12, 2019
    Posts:
    6
    Thanks for the answers and I have another question.
    In NVP, the Power of the Engine is affected by the Transmission Gear state. However, in reality, it is the Power(Bias) of Transmission that is affected by the Gear.
    Will there be any changes to this in NVP 2?
     
  2. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    I am not sure what you mean by the 'bias' of transmission. Power is power, it is work done in time and gearbox does not change it if losses are ignored. What it does change is the torque. It is normal for a vehicle with larger gear ratio to accelerate better, but at a cost of top speed, since the engine spends more time in the power band.
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    This got a bit burried in the discussion, but here is the newest development preview link.
     
  4. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    There are a few things:
    - The car is four wheel drive with 30% of the torque sent to the front.
    - Rear tires are set up to have more grip which also prevents oversteer.
    - Clutch-type LSD both front and rear.
    - Suspension setup is such that there is no tendency to oversteer.

    But this is not really that relevant since I just finished porting the settings and telemetry from V1 demo and in the future all the demos will have this adjustable in-demo, including the differential settings.
     
    Guacamolay likes this.
  5. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,041
    Ok thanks for info, look forward to trying to finished article. The setup sounds like a modern 4WD Rally car but again those can spin on the spot, so I am still a little intrigued as to what is stopping it :)
     
    RichardSim likes this.
  6. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Mirror support done.
    From now on NWH Vehicle Physics 2 supports Photon Unity Networking 2 and Mirror.
     
    RichardSim, Weezel and Guacamolay like this.
  7. Praetorsoft

    Praetorsoft

    Joined:
    Oct 9, 2016
    Posts:
    14
    Excellent! Thanks for all your hard work.

    Any news regarding release date for v2?
     
  8. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Working on demo and documentation as we speak. The code is done. So ~10 days.
     
    overthere, slimshader, Weezel and 2 others like this.
  9. Praetorsoft

    Praetorsoft

    Joined:
    Oct 9, 2016
    Posts:
    14
    Looking forward to it!
     
  10. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
  11. Praetorsoft

    Praetorsoft

    Joined:
    Oct 9, 2016
    Posts:
    14
    Looks good!
     
  12. eclipseanu

    eclipseanu

    Joined:
    Jan 6, 2017
    Posts:
    10
    I suggest considering a Discord server to find answers easier, watch updates easier, even faster support since anyone can help with mundane questions. Most of the assets I'm using have one and it's a lot better than a forum, especially when all info is crowded in one thread. As a matter of fact, I wouldn't even come to this forum if I wasn't watching v2 progress.

    Can also help with configuring and setting up if you're not familiar with Discord.
     
    Freznosis likes this.
  13. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    174
    Hi, I am new to the asset and it looks great after initial testing but I have a problem: I don't know how to configure WheelControllers where the pivot is not in the rotation center of the actual wheel.

    Attached image is my case with the tractor, red dot is the pivot that I need to respect with the wheel rotation as it has to rotate according to the specification. How can I configure WheelController to have an offset from the pivot point for the "collider"? I've tried with Rim Offset but that doesn't seem to have an effect.
     

    Attached Files:

  14. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Three green debug gizmo shows the actual position of the wheel as the WheelController sees it.
    It is also where ground detection happens.
    If you want to move the green gizmo outwards use the positive Rim Offset (say 0.2) and watch what happens with the gizmo. Try adjusting it at runtime and see what it does. Rim offset exists exactly for the case where the steering pivot is not at the center of the wheel.

    Also check the documentation for WheelController V4, second image:
    http://nwhvehiclephysics.com/doku.php/NWH/WheelController3D/WheelController
     
    Last edited: Mar 18, 2020
    slimshader likes this.
  15. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    174
    Indeed it seems that is exactly what I need, problem is as I mentioned before, when I change Rim Offset values in the editor, nothing happens (green gizmos don't move). Using version 1.9.4, Unity 2018.3.10. New update (and docs) looking great btw.
     
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    I have just tried the demo for WheelController v3 (the one included with NVP 1.9) which has the side offset option and it works. It could be that the gizmo is not positioned correctly.
    Could you try setting the offset to a large value and see if the visual moves?
     
    slimshader likes this.
  17. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    174
    Was unable to record a video but made screenshots of a changes to the Rim Offset in the demo scene
    rim 1.JPG rim 2.JPG rim 3.JPG rim 4.JPG
     
  18. mitis

    mitis

    Joined:
    May 21, 2013
    Posts:
    40
    hi my friend when to wait for version 2 release
     
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
  20. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    174
    You mean it will not show gizmos correctly in Editor mode, yes?
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    No, it will show the gizmo at all times at the position of the wheel but will not move the wheel out of play mode since it is not executing out of play mode. The gizmo out of play mode is intended to adjust wheel radius and width. Sorry for the confusion, should have cought that earlier but I assumed you tried steering in play mode when you said it was not working.
     
  22. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    174
    Hm I am indeed confused now, not sure what you mean by "will not move the wheel out of play". I do not want to move the wheel... I just want to configure the WheelCollider in Editor mode that would take Rim Offset into consideration so I can visually set it up properly (like radius and width). Do I understand correctly that I can ONLY do that in Play mode? (so I must save the values and put them in Editor mode)
     
  23. slimshader

    slimshader

    Joined:
    Jun 11, 2013
    Posts:
    174
    I just tried changing the value of Rim Offset in the Play mode, nothing changes as well. Is there a way we could contact directly?
     
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Documentation for V2 has just been finished.
    Documentation

    Class reference is on the bottom of the sidebar.
     
    Bero89, millar5001, Freznosis and 2 others like this.
  25. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    65
    I just have an issue in my VehicleController inspector window, it seems to reload/save everytime, im using Unity 2019.3.3f1.
     
  26. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    What do you mean by reload/save everytime?
    Did that happen in previous versions of Unity?
    2019.3 is notorious for a lot of editor bugs since they changed a lot of things around but it could be that they
    have changed the behavior of SetDirty() or some other function.
    If you could share a bit more details that would be great, although I am developing NWH Vehicle Physics 2 in 2019.3 and at the moment it does not have such issue, but also it will not be out for a few days.
     
  27. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    65
    uatanks likes this.
  28. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Okay, I took a look at the code and immediately spotted the issue:
    VehicleControllerInspector.cs, OnInspectorGUI() function:
    Add

    Code (CSharp):
    1. EditorGUI.BeginChangeCheck();
    at the beginning of the function and
    then wrap the line 73 so it looks like this:

    Code (CSharp):
    1. if(EditorGUI.EndChangeCheck())
    2. {
    3.   serializedObject.ApplyModifiedProperties();
    4. }
    Last line, SetDirty(), can be removed as it is pretty much obsolete at this point.
    If you contacted me through email I would have sent you the file but hopefully you will be able to fix it this way too.
     
  29. TiToMoskito

    TiToMoskito

    Joined:
    Jan 28, 2014
    Posts:
    65
    Thank you very much, i will fix it myself :)
     
  30. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    New monster truck just finished. The asset needed a halo vehicle to showcase and test the new features as they are added and this one has it all.
    Hopefully you like it.

    MonsterTruck.PNG
     
    Last edited: Mar 24, 2020
  31. Praetorsoft

    Praetorsoft

    Joined:
    Oct 9, 2016
    Posts:
    14
    Beautiful!

    I find monster trucks perfect for testing physics because you can see much of what’s going on. Plus they are really fun to drive :)
     
    NWHCoding likes this.
  32. RichardSim

    RichardSim

    Joined:
    Dec 15, 2013
    Posts:
    14
    Have to agree - good choice in test vehicle! The sports car while pretty I'm assuming was the cause for a lot of bad behaviors with such low ground clearance.

    An offroad vehicle aligns with my needs much better too. :)

    I'm excited to see the release getting so close! Can't wait to try it out.
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    The sports car was the second test vehicle after the old SUV which is more generic but some behaviors, especially tire grip, are more obvious on sports vehicles while the others are more obvious on the monster truck.

    By the way, here is the replacement for the 8x8. The model is based on TwisT's design (CC-BY licence) but it needed a lot of rework and a new set of textures.

    upload_2020-3-25_23-38-56.png
     

    Attached Files:

    Last edited: Mar 25, 2020
  34. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Also a video of the 8x8 truck. A few issues to tackle but it is 90% there.
     
  35. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    A short video demonstrating VehicleSetupWizard script from NVP2. I have made it reasonably robust but some vehicle model basics are required, such as correct pivots and Unity-correct rotation. Also, the values that the vehicle ends up with in the end are the defaults and manual tweaking will be needed to get the best results.
    It shortens the vehicle setup process by at least ~10 minutes and together with Validate Setup function that runs validity checks on all components should save a lot of troubleshooting time.

     
  36. Bero89

    Bero89

    Joined:
    Jan 17, 2017
    Posts:
    5
    Wow! i cant wait for the nice Update =)
    Release you this as a Free Update for Owner or mus i buy this new ?
     
  37. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    Very lovely! Especially the offroad stuff. Just one question. Is wheel denting separate component from mesh deformation? I have my custom solution for meshes so just wondering.

    EDIT: i didnt find anything about wheel denting in docs.
     
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    There is no wheel denting. There is just wheel wobble. But really a nice suggestion - I will add a "Mesh Deform" toggle to the DamageHandler. I have many ideas for the future of the damage but those will have to wait until after the release. For now the framework is there but smoke coming from under the hood when engine is damaged, for example, would be a nice addition.
     
  39. DeathRace26

    DeathRace26

    Joined:
    May 26, 2019
    Posts:
    75
    No, that is not what i meant :D. I was talking about a rim benting. Like the whole wheel gets curved around it's pivot, so in result car steers in direction it normally wouldn't be able to. My question is, if this is separated from mesh deform component or combined, with refferences to wheels
     
  40. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    I have just added a toggle that turns mesh deformation on or off. That way you can leave all the damage stuff and handle deformation yourself if you want.
     
    GLID3R82 likes this.
  41. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    265
    Does anyone have a reasonably accurate solution for calculating impact force that takes the mass of the vehicle into account?
     
  42. FIReedM

    FIReedM

    Joined:
    Jan 3, 2017
    Posts:
    1
    Hey guys, sorry for the noob question but I can't identify the variable that defines how much steep can the vehicle climb. I want the sport car to be able to move forward on steep surfaces instead of stopping at the first surface relief. I read the manual, and compared the values of the sports car with the monster truck, and can't figure it out. Appreciate the help. Thanks.
     
  43. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    One thing you could do is take the collision.impact value and divide it by Time.fixedDeltaTime. This will give you the force which should be proportional to the mass, given that the collision is head on.
     
    GLID3R82 likes this.
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Make sure you are not getting stuck on terrain. The sports car has quite a low collider and the collisions in Unity, even when physics material's friction is at the lowest, are quite grippy.
    Other than that: locked diff and longitudinal force coefficient (WheelController) are the most important in NVP1.
     
    GLID3R82 likes this.
  45. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    265
    This is completely over my head. Is this something from NWH, as this doesn't exist in unity as far as I am aware. Do you have an example if one of your demos?
     
  46. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    NVP2 uses it to determine damage.

    Here is the exact code:

    Code (CSharp):
    1. void OnCollisionEnter(Collision collision)
    2. {
    3.     float collisionForce = collision.impulse.magnitude / Time.fixedDeltaTime;
    4. }
    Of course, the higher the mass of the vehicle the higher the deceleration force will be needed therefore larger impulse.
     
  47. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    265
    Thanks, that works quite well.
     
  48. nobluff67

    nobluff67

    Joined:
    Nov 3, 2016
    Posts:
    265
    Do you have any documentation for improving performance of asset? e.g. disabling skid marks, stuff like that?

    ... and will NVP2 improve performance, or maybe reduce due to added features?

    and how is the release going? has it been delayed?
     
  49. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    NVP2 introduced this. Click on the link and it explains it there.
    I have just done a comparison of built scene with similar vehicles in version 1 and 2 and the performance per FixedUpdate() is about the same for similar settings but the Update() and LateUpdate() are much faster. This is in large part due to improved skidmarks and general optimizations in regards to effects and sound.
    For more info about release check the post below.
     
    GLID3R82 likes this.
  50. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    1,419
    Here is the demo (Win64) for the NWH Vehicle Physics 2.
    The asset will be submitted on Sunday, 5th of April. Expect a few days for it to get approved before it is available on the Unity Asset Store.
     
    Last edited: Apr 2, 2020
unityunity