Search Unity

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. blamejane

    blamejane

    Joined:
    Jul 8, 2013
    Posts:
    203
    I understand what to do with the individual gear ratios, but what do we do with the "final gear ratio" number? Is that the gear multiplier?
     
  2. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133
    Nevermind. I found the demo in previous page, but I dont know how to use it. No menu, no tutorial how to use it for beginners, only car driving. I think to buy NWH because of features. But I dont know how support. I have RCC also, its good asset, but compare to NWH different style driving. Very agressive driving. It is hard to setup car which start moving without smoke on wheels.. For easy driving I tried demo and I think NWH is better than RCC.
    Fot racing games RCC is good, but not for easy driving e.g. in the city. Too agressive.
    Another thing is Photon, in RCC theres no lobby room, no simple menu scene with Photon multiplayer. And theres no PUN 2 support. I would like to know how about NWH about that?
    Another thing is support. RCC has good support, publisher helps, but you have wrote sometimes a few emails about one things and remind what you need. So he answered after a few days, or week, or if you dont remind - never.
    .So Im still thinking about buying NWH but if it lacks like RCC in some cases, I will not pay money.
     
  3. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello, I respond to emails the same day, usually withing a few hours. There has been an instance or two where the mail has been buried (I do get a lot of them) so if I do not respond within 24 hours please do resend.

    Photon support is for vehicles only. I have not implemented any lobbying or menus or anything like that since NVP is not a complete game asset - it is a vehicle asset. Some people will use it in racing games, some in GTA style games, etc. and I am leaving the implementation of such things to the game developer. Also, making a scene with a lobby would be redundant since Photon itself has demos for different cases - and things like taking ownership are universal. What NVP does is takes care of the car itself, the rest is pretty much Photon domain.
     
  4. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    99
    Any advice on how to make a cruise control feature (activate at a certain speed and the car handles the acceleration automatically uphill / downhill) ?
     
  5. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Interesting thing about this is that cruise control was one of the first things that I implemented in the first version of NVP (that never actually got released). Added it to TODO as that is something that takes only a few minutes to implement but can be useful (you are not the first to ask).

    So, the bare minimum would be:


    float speedDiff = targetSpeed - currentSpeed; // Positive when too slow, negative when speeding
    float sensitivity = 1f;
    vehicleController.input.vertical = Mathf.Clamp(speedDiff * sensitivity, -1f, 1f);


    Or if you want something very accurate then I would recommend PID controller of some kind. The downside of the code above is that it will always make the car catch up to set speed, but never actually reach it. On the plus side - it will even handle braking. If you do not want braking clamp the input between 0f and 1f.
     
  6. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    99
    Many thanks, that should be sufficient for my needs ;)
     
  7. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133

    Ok, but in Photon mulitplayer It also will be demo scene with FPS character with EnterExit system?
     
  8. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Does anyone know how to fix the monster truck in android builds? It happens even in the provided NWH demo apk:

    It looks just fine in the Unity Editor...I tried to reimport it but it didn't help.
    Thanks
     
  9. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Wow, that is really interesting. Monster truck is using skinned mesh and I am going to assume that that is the cause of the problem. Will check it out!
     
  10. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Thank you! If this can help, i tested it on my phone running android pie, and i get the same glitched texture both in the demo apk you provided and in my custom build.
     
  11. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Just ran it on Xiaomi Mi Max 3 running Android 9.0 and this is the result:

    Screenshot_2019-03-26-10-40-38-611_com.NWH.VehiclePhysics.png

    Did you do anything else except extracting and running it? Could you post the model of your phone? This smells of a Unity bug of some kind since that model is not modified from code or anything like that, meaning that the glitch IS because of the skinned mesh.
     
  12. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Sure, tested on a galaxy s8+ running android 9...hope it helps!
    And nope, i have not done anything else, and as i said i get that even with the demp apk. I don't know it's just weird
     
  13. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    I have dug around some and it seems that this might be the issue:
    https://issuetracker.unity3d.com/is...n-newer-mali-devices-and-gpu-skinning-enabled

    Bug has been introduced in or before 2018.3 and fixed in 2019.1 (which is still in Beta).
     
  14. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133
    I tried and In demo Enter/Exit system exists...
    Well, publisher NWHCoding, how hard to answer : "no"..
    I see that I shouldnt buy this package because support isnt good as I thought.
     
  15. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    This has been answered in post #553.
    If there is interest in such script tho, I can add it to the changes for the upcoming update (a list of upcoming changes can be seen here). But as I mentioned in 553 - NVP is not aiming to be a complete game asset but a vehicle asset. There are many ways to implement vehicle changing in multiplayer scenes and it all depends on game design.
     
    Max1982 likes this.
  16. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Small bug-fix update coming is getting pushed tomorrow (allow a few days for it to get approved) with following changes/bug fixes:
    • Add track texture direction on tanks.
    • Fix missing Photon multiplayer scene.
    • Improvements to the Photon scene.
    • Fix sometimes not shifting in reverse if the vehicle is creeping forward in neutral.
    • Add cruise control.
    • Fix: If vehicle flips over and transmission is set to Manual, throttle can get stuck at 100%.
    If I missed something do comment below.
     
    Max1982 likes this.
  17. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133
    Ok, thank you for reply.

    I have a question. Is NWH support PUN Rally Tutorial? Or If I will buy, could you help me integrations this asset with NWH? Its important to me. Thank you.
     
  18. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    No, PUN Rally Tutorial is not included. What is included is basic car setup where you can spawn one or more vehicles and drive them around over nework.
     
  19. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Cruise control has been added to driving assists:

    upload_2019-3-28_17-37-39.png
     
    Max1982 likes this.
  20. Max1982

    Max1982

    Joined:
    Oct 16, 2014
    Posts:
    133
    Ok. There are only one spawn point in the Photon scene? Or it is possible to have 3 or 4 spawn points?
     
  21. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Of course it is. There is an inifinite number of Vector3's running around.
    One way to do it would be having multiple points in, say, a list and then selecting one point at random - this has a problem of still being random so spawning two vehicles at the same point will happen.
    Better solution would be to do an overlap sphere and check if there is a vehicle in the area where you want to spawn the vehicle, and if there is choose one random point somewhere to the side and do the same check.
     
  22. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Update 1.9.1 is out. Changes can be found in #566.
    One thing that I did forget to ship with the update is multiple spawn points for the Photon scene. My bad there.
     
  23. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    99
    Noticed a BUG : Drastic power cutoff if a car is started while being in 1st gear.

    Reproduce :
    - Open Island(Desktop) scene (tested in a new project with latest NWH version).
    - Modify the sports car to be a manual.
    - Start game, go to car, start it, press 1 to shift into 1st gear. Get out the car (so the engine stops).
    - Get back in the car, wait for it to start, accelerate.
    The power is drastically cutoff. From the available 250 (Max Power) only 33.02 is put down. This can be seen by adding Debug.Log("UserInput = " + userInput + " Power = " + power); at the end of Update() in Engine.cs.

    If the car is set to gear 0, stopped and restarted, the full power comes back on.

    Looking fwd for your feedback
    Thanks
     
    NWHCoding likes this.
  24. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Will check this out and push it together with Photon spawn point fix.
     
    Jbs_GameZone likes this.
  25. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    278
    When the player leaves the vehicle, the wheel collider is replaced by a simple Raycast, and this causes the vehicle to get into obstacles in some situations.

    Do you have any options to keep all raycast active all the time?




    One more note ... The angle of the wheels is with a big bug. The wheels did not see when the vehicle is not accelerating.
     
    Last edited: Mar 30, 2019
  26. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    99
    Reporting a second BUG (please treat this with higher priority that the previous one) :

    Description : When in car is beached, and it is in gear (manual transmission) the rpm will never drop when lifting off the throttle.

    Reproduction :
    1) Open Island Scene
    2) Modify Sports car to Manual, shift to 1 and go and beach the car (try climbing the wooden pallets such that some of the wheels will lose contact with the ground).
    3) Accelerate and let off the throttle ( the RPM should stay at a fixed value and not drop back )

    Below is a picture showing (constant) high rpm at 0 vertical input and 0 power.
    NWH_1.png

    Thanks
     
    Last edited: Mar 30, 2019
    NWHCoding likes this.
  27. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Have you tried this with 1.9.1 that was released two days ago? Demo scene layout seems like 1.9.0 or older. This has been mitigated by adding friction to the wheels when freely spinning, but I will also add engine drag in the next update during the upcoming week.
     
  28. thedetective123

    thedetective123

    Joined:
    Aug 20, 2017
    Posts:
    2
    I have a suggestion:
    * Start a giveaway
    *Be biased and select me as winner.... This vehicle physics looks awesome though....:eek:

    If you give any offer or sales..... How can I know?
     
  29. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    There was a May Madness sale last year, who knows - maybe the history will repeat itself ;)
     
  30. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    278

    no answer?
     
  31. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    No worries, it is getting looked at.
     
    Marcos-Schultz likes this.
  32. Marcos-Schultz

    Marcos-Schultz

    Joined:
    Feb 24, 2014
    Posts:
    278
    Thank you.

    I'm putting some logic behind your product with the logic of my product to make a game where vehicles collide.

    I am facing some small problems when a vehicle goes up with only one part of the wheel in another vehicle, so I asked the question.

    Anyway, thanks for your time. I look forward to the answer.
     
  33. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Update 1.9.2 will be out on Thursday with the following changes:

    • Improvements to freeze options preventing vehicle being detected as inactive while still moving or being spawned.
    • Fixed spawn point in Photon scene.
    • Fixed vehicles lacking power when using manual gearbox and vehicle is exited and entered while in 1st (or any other than neutral) gear.
    • Improvements to RPM drop when powered wheels are in the air with 0 throttle applied.
    • Added “Switch to Single Ray When Inactive” option (on by default).
    • Improved engine braking when throttle is lifted.
    • Encapsulated engine.starting and engine.stopping.
    • Separated “General” foldout into “General” and “Optimization”.
    • Fixed brake torque not being applied properly when wheel is in air (i.e. to stop the wheel spin)
    • Fixed vehicle not being able to apply brakes when still and manual transmission used.
    • Fixed engine sound volume when using manual transmission and braking with one or more of the powered wheels in the air.
    • [WC3D] Fixed brake force calculation when wheel is in air.
    Quite a lot of changes so I will do an hour or two of testing tomorrow and immediately upload afterwards.
     
    Last edited: Apr 2, 2019
  34. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Hello, I have faced a bug that I can't fix so I am asking here...
    Basically I put the demo vehicles in a test scene and i have disabled them all, then I have slightly edited the VehicleChanger.cs adding this line:
    Code (CSharp):
    1. vehicles.gameObject.SetActive(true);
    before this one:
    Code (CSharp):
    1. vehicles[i].Active = true;
    in DeactivateAllExceptActive().

    I am basically trying to activate only the vehicle that I want to drive when i press the change vehicle button.
    It kinda works but I get this error when trying to change the vehicle (calling that ChangeVehicle() function):

    It's something at the beginning of the Start() function in Engine.cs...it seems that the vehicle controller is not (yet) loaded but i am not sure.
    I have also tried to play with scripts execution order but that didn't help very much.
    Any idea? Maybe my approach is not correct?
    Thank you
     
  35. thmapps

    thmapps

    Joined:
    Dec 1, 2014
    Posts:
    1
    can you please send me link of adding mobile controls
     
  36. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    There is a mobile control setup in the Android demo scene. Also, check the Input section of the manual - it explains the idea behind the input and the input states in NVP.
     
  37. Xeon_555

    Xeon_555

    Joined:
    Nov 30, 2014
    Posts:
    2
    Last edited: Apr 8, 2019
  38. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello and sorry for forgetting to reply to that one. I did see it on the phone but it got buried until I got back to office and I later forgot about it. Thank you for reminding me, might as well answer it here:

    I would recommend increasing spring.bottomOutForce inside WheelController.cs, line 611. There is a coefficient at the end that is currently 0.5 (arbitrary value). You can try bumping it out and it should solve the problem.
    The thing happens if there is not enough force to push the vehicle up - i.e. bottoming out - but while in a real car this would be handled by suspension arm hitting a rubber stop here it is handled by appoximation which has been tuned a bit to the soft side to support spring strength of near 0 without bouncing.
     
  39. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    99
    Hello

    Tested now with 1.9.2 and everything is fine, both bugs that I reported (car beached case and starting the car in 1st gear) are fixed.

    Many Thanks,
    Jbs
     
  40. Jbs_GameZone

    Jbs_GameZone

    Joined:
    Dec 14, 2018
    Posts:
    99
    Reporting an issue with cruise controller.
    It doesn't work properly when DeactivateOnVerticalInput is checked. It disables automatically itself.

    Reproduce : Open island scene (NWH 1.9.2), start the sport car, goto in inspector set cruise speed at 10 and try to enable the cruise control, it will disable itself back instantly.

    First observation : Correct the lower input value in the if clause : if(deactivateOnVerticalInput && (vc.input.Vertical < 0.1f || vc.input.Vertical > 0.1f)) to -0.1f

    Second observation : Even with the first obs correction the cruise control will disable itself at the next iteration because the vc.input.Vertical still has the value that the cruise control itself has set previously (and not the input from the user).
    From what I've checked this is due to the fact that Unity's FixedUpdate() runs(or can run) multiple times per Update() frame. I have the fixedtimestamp at 0.015ms which means 66 calls per second whereas the framerate tops at 30fps on mobile. The cruisecontrol logic is called from VehicleController.FixedUpdate() function whereas the input from the user is taken in the Update() function of the input managers (DesktopInputManager for e.g.).

    Beside this, the rest of the logic is ok, so I did an ugly workaround till this is fixed (added a reference to the input manager directly in the cruise control and checked the vertical value directly from it, instead of asking it from the vehicle controller which wasn't updated yet).
     
    Last edited: Apr 10, 2019
    NWHCoding likes this.
  41. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Thanks for the spot. Apparently I managed to miss this one even if I drove pretty much all the vehicles in the scene with it enabled.
     
  42. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Hello @NWHCoding, I am trying to setup the brake lights of one of my in-game cars.
    The mesh body comes with 10 materials, and one of them is the one that should change (by toggling emission on/off).
    I can't figure out how to set this up correctly because the vehicle controller wants a mesh renderer, but if i just pass the whole body mesh then of course it changes all the car body's materials, and that's not how it should be...any idea (other than adding a mesh on top of the actual brake lights)?
    I feel it's something related to the mesh import settings, but i am not sure. I suppose that the lights should be separated from the body somehow, like the ferrari car in the demo scene...or maybe i need something like Blender?
    Thank you
     
    Last edited: Apr 12, 2019
  43. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    34
    Hi. Is it possible to have more than one sound source for the car engine? I'm thinking if we could specify x number of sounds and possibly specify the rpm range in which to use each sound then we could have a much more realistic engine sound during races. I've seen something like this being implemented on Youtube (
    ) but am having problems trying to incorporate it into NWH. Cheers.
     
  44. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    I would suggest going to VehicleLight class (line 24 in Effects/Lights.cs) and adding:

    public int materialIndex;


    or similarily named variable and later on in the same class replacing:

    mr.material.EnableKeyword("_EMISSION");


    with

    mr.materials[materialIndex].EnableKeyword("_EMISSION");


    That should work fine for your use case.
    Also added to TODO for next version.
     
    lynx89_ likes this.
  45. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Hello,
    out of the box unfortunately not. I have already made a similar system for the game I am currently developing so I will for sure think about moving that over to NWH Vehicle Physics. Original idea with the current system was that the sound result was very similar with much easier setup process and not many people have access to multiple RPM files of the same engine. Still, I do have an idea how to implement if flexibly and will add it to TODO list as it is a great idea.
    To implement it I would recommend modifying the EngineIdleComponent.cs and throwing the code in Update() and replacing it with your code. Added to TODO for the next update.
     
  46. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Hi @NWHCoding , I am trying to implement the vehicle damage deformations but something's wrong.
    For some vehicles it works, for some it doesn't. But even when it works, it only works one time.
    No matter if I fix the vehicle later, it just doesn't deform anymore.
    Do you know what the problem could be?
    I use mesh colliders on all my vehicles (not box colliders) but i don't know if this info is useful...I tried to play a bit with the damage settings but no matter what, I keep getting the same issue.
    Thank you
     
  47. NWHCoding

    NWHCoding

    Joined:
    Jul 12, 2012
    Posts:
    759
    Are you having the problem in the demo scene too?
     
  48. GLID3R82

    GLID3R82

    Joined:
    Aug 7, 2013
    Posts:
    9
    Tried the demo scene taken from first page of this forum... yes, the collision system does'n work properly... starting with red sportscar, if I drive at high speed against the blue sedan... the collision is high damage on the red sportscar but minimum damage on the blue sedan... and trying a second impact... nothing happened! So, trying the same impact at the same high speed but driving the blue sedan, the same situation: deep damage on the blue sedan but very little damage on the red sportscar... and also trying other impacts: the car I drive doesn't feel to be damaged any more... everytime only the first contact... but sometimes when I reset and drive again red or blue car, the first collision (even if I drive at high speed) doesn't produce any damage at all... but it happens only few times like a bug, like the first collision is the considered like the second or third collision etc. in fact nothing happened. Very strange is when I drive other demo vehicles and damage system seems to be always completely off... now I try every vehicle and I will bring a description for every vehicle.
     
    Last edited: Apr 15, 2019
  49. adrianprusinski91

    adrianprusinski91

    Joined:
    Mar 26, 2019
    Posts:
    1
    Hi,

    I am occuring a problem with floating of a vehicle. You can see it at video

    Do you know what might be a cause of it?
    That happens when im not using rim collider.
     
  50. lynx89_

    lynx89_

    Joined:
    Mar 1, 2018
    Posts:
    27
    Well yes, just tested in the demo scene...same result. No damage at all, tried with different vehicles
     
    NWHCoding likes this.