Search Unity

Randomation Vehicle Physics 2.0 - Now open source on GitHub!

Discussion in 'Assets and Asset Store' started by JustInvoke, Mar 14, 2015.

  1. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    I respect that. Good luck man!
     
    angrypenguin likes this.
  2. toadie-festino

    toadie-festino

    Joined:
    Nov 5, 2013
    Posts:
    6
    Hi Dev, Hoping you're still around... I've previously seen requests from people asking you for a touch screen steering prefab. Did you ever create anything that works with your package? For some reason my own implementations are just not working out... I'm wanting to be able to turn off tilt (which I can script) and let my players use an onscreen joystick..

    Hoping you have a prefab or some tips..

    Kind regards
     
  3. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    The BasicInput script has a steer method that accepts normalised input.

    There are a lot of steering wheel scripts if you do a google search, even take a look at the asset store. All you need to do is send the value of the steer wheel to the BasicInput script or Mobile input script to steer the vehicles, its straight forward.
     
    JustInvoke likes this.
  4. toadie-festino

    toadie-festino

    Joined:
    Nov 5, 2013
    Posts:
    6
    Oh.. I hadn't seen that.. i'll look again.

    thanks
     
  5. Shizola

    Shizola

    Joined:
    Jun 29, 2014
    Posts:
    475
    Aww such a shame this has been discontinued, I wanted to buy it!
     
  6. TymNetwork

    TymNetwork

    Joined:
    Jan 16, 2014
    Posts:
    84
    I still use every update you made! You did good. I am a happy customer, and always will be.
     
    Greg-Bassett and JustInvoke like this.
  7. martman100

    martman100

    Joined:
    Sep 4, 2013
    Posts:
    44
    I am using the pickup prefab that came with the asset with out of the box settings and it is jumping way too far and high when it hits a ramp. I have modified the mass, angular drag and drag but have yet to get a feeling that it jumps like a real vehicle. What is the best approach to get a more accurate vehicle jump? Is it better to increase drag and mass and then increase power and suspension settings to handle the extra mass/drag?

    I also really hate to hear that you are calling it quits. Is a very nice asset!
     
  8. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Thanks for using my asset.

    Mass doesn't change fall speed and increasing the drag will actually make it fall slower. The angular drag only affects rotation speed. You have to either increase the gravity in the project settings, use the ConstantForce component, or use the Rigidbody.AddForce function in a script. The suspensions will have to be tweaked to counter this.
     
    artisticmechanics and TymNetwork like this.
  9. Hoarmurath

    Hoarmurath

    Joined:
    Mar 22, 2016
    Posts:
    27
    will u ever put the asset back on asset store?
     
  10. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Almost certainly not, but in the distant future I might make it open source.
     
  11. lazygunn

    lazygunn

    Joined:
    Jul 24, 2011
    Posts:
    2,749
    A community driven Randomation would be really great when it came around, understandably after support had ended
     
  12. nukeD

    nukeD

    Joined:
    Feb 12, 2009
    Posts:
    411
    Hey Justin, i used to follow the Fastest Meal, but i see that you've stopped the development and the source is up for grabs. I guess it uses Randomation. So it could be a starting point for some guru to continue your legacy and evolve RVP. What do you think?
     
  13. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    It doesn't use RVP, but I did copy the suspension calculations from RVP and use them for the karts. Everything else is made specifically for that game since I felt that RVP was overkill for a kart racer. The game also has some nuanced mechanics like the jumping and drifting that aren't possible with RVP out of the box.

    I will probably make RVP open source near the beginning of next year because that's when support ends. If I release it now, customers who purchased it near the end of its life might feel cheated because they could have waited a bit longer and gotten it for free.
     
  14. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Hi there Randomator,

    I have a very simple but important question. Can I let an AI car (the one at the little circuit for instance) drift as well?
    Just like how the player does you see?
     
  15. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The easiest way to do this reducing the sideways friction of the rear wheels. This way the car will automatically slide when it turns, and the AI will still try to stay on track like it usually does.
     
    Justice0Juic3 likes this.
  16. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Thanks for the quick reply.
    I know it's not the right time already, but I just wanted to let you know that I'm always excited what you're going to develop next. ;)
    Cheers!
     
    JustInvoke likes this.
  17. charmandermon

    charmandermon

    Joined:
    Dec 4, 2011
    Posts:
    352
    Hi I purchased both of your kits and now both have been removed from the store... Can you send me a link to the second most recent version of your kit. Thanks in advance.
     
  18. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    If you purchased through the Asset Store you will be able to download it through the editor. It is still there, I just checked.
     
  19. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    It should still be available in the downloads section of the asset store, like Meltdown said. If you still can't find it then you can email me your invoice number and I can provide an alternate link.
     
  20. charmandermon

    charmandermon

    Joined:
    Dec 4, 2011
    Posts:
    352
    Great thanks
     
  21. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    @RandomationGames I'm having a small issue with the package.

    I'm trying to change my AI trucks engine speed, if they are far behind in the race, to allow them to catch up.

    So I make them a bit faster, and do something like this...

    Code (CSharp):
    1. SpeedModifier = SpeedModifier + catchUpModifier;
    2.      
    3.         var keys = new Keyframe[3];
    4.         keys[0] = new Keyframe(0, 0.86f);
    5.         keys[1] = new Keyframe(1.63f, 0.97f);
    6.         keys[2] = new Keyframe(SpeedModifier +   catchUpModifier, 0.01f);
    7.  
    8.         _gasMotor.torqueCurve = new AnimationCurve(keys);
    9.         _gasMotor.GetMaxRPM();
    10.        
    And then once the truck has caught up, I return its engine speed to what it was before...

    Code (CSharp):
    1.  
    2.         var keys = new Keyframe[3];
    3.         keys[0] = new Keyframe(0, 0.86f);
    4.         keys[1] = new Keyframe(1.63f, 0.97f);
    5.         keys[2] = new Keyframe(_originalSpeedModifier, 0.01f);
    6.  
    7.         _gasMotor.torqueCurve = new AnimationCurve(keys);
    8.         _gasMotor.GetMaxRPM();
    But for some reason, after catching up, the vehicle still remains faster, I have checked that all the correct values are being set. Is there something I'm doing wrong, or is there a better way you can recommend for me to allow my vehicle to catch up, that I can restore to the original speed again easily?

    Thanks
     
  22. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    By default, vehicles will not slow down at all unless they brake or face an incline. Even though you're lowering the top speed, the vehicles are continuing to roll at their increased speed (steering does not lower speed much either). A potential solution is increasing the axle friction of the driven wheels to something like 0.2, that way the vehicles will slow down when their top speed is lowered, but can still drive normally.

    Also, with your code it seems like SpeedModifier is set to equal itself plus the catchUpModifier, and then referenced in the keyframe creation with another addition of the catchUpModifier. I'm not sure if this is affecting the outcome on your end, but when I tested it I removed the redundancy.
     
    Meltdown likes this.
  23. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    @RandomationGames Is there an easy way to prevent my vehicles from driving up the barriers on the side of my track. I have them on a seperate collider and on a different layer, but in some cases the player can drive up them, which I really don't want.

    PS : I can't just make them more frictionless as they are perfect for racing as the young are now.

    They also don't have a ground surface instance on them.
    Thanks
     
  24. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Have you tried removing the layer from the wheel cast mask on the GlobalControl script? This way, wheels will completely ignore the walls.
     
    Meltdown likes this.
  25. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Thanks, I'm sure I had tried that previously at some point, and it didn't make a difference. But for now it seems to work.
     
  26. ZloyCrek

    ZloyCrek

    Joined:
    Nov 22, 2016
    Posts:
    2
    Hello, I'm using your Asset and during the game there is a big load on the processor. As it turned out after a few scenes downloads (ie. run did not stop, and the scene loaded from scripts) that use your Asset begins the load on the processor, the speed ranges from 500ms to 12000ms, provided that this average to about 10ms. When tests revealed that the problem lies in the call fixedupdate () from Wheel.cs, also comes with a big load Physics.RaycastAll (...) in GetWheelContact (). Forgive help establish where the error may be located on our part, or with your and eliminate it.
    3y4_rwR-0L4.jpg _HR-zFSG9pw.jpg
     
  27. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    This is a problem many customers have faced, but there is not much that can be done as far as I know. I compared the performance of RaycastAll, RaycastNonAlloc, and Raycast. Each one takes roughly the same time to execute and there is no noticeable difference in garbage collection. Since raycasting is required to detect contact points for each wheel, the only optimization I've been able to make is through the wheel groups on the VehicleParent script. The wheel groups allow you to split up the raycasts for a vehicle across multiple frames. For instance, you can have a car with 4 wheels do one raycast per frame over 4 frames, rather than 4 raycasts in one frame. This makes the physics less precise in exchange for much better performance. You can read more about it in the manual.

    However, 6600 raycast calls each frame is an awful lot, how many vehicles are active at once?
     
    ZloyCrek and Meltdown like this.
  28. ZloyCrek

    ZloyCrek

    Joined:
    Nov 22, 2016
    Posts:
    2
    Thanks for the answer. The problem is that these problems are caused by repeated call scenes. If the cause of the Unity one scene for the entire session, the problems will not, but after 4-8 downloads new scenes, this problem occurs.
    The game uses 40 wheels (4 per car).
    And we are well aware that the problem is not RaycastAll, for it is only 5%.

    ***
    upd
    ***
    Thank you, that was fixedtime was 0.01, and because of this sometimes Unity did not have time to process fixedupdate () and processes began to lag. I do not know why it was so, but fixed at 0.02 everything went smoothly.
     
    Last edited: Nov 23, 2016
  29. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    It's good to know that the fixed time was causing the problem, but I'm still curious about what you meant by downloading new scenes and how that impacted the performance.
     
  30. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    RVP is now open source on GitHub.

    Support also ended on New Year's. It's pretty much exactly the same as it was in version 2.09 on the asset store, except the JS scripts and prefabs have been removed. Focusing exclusively on C# will make it easier to maintain in the future.

    This is my first project using GitHub and source control in general, so I'm open to feedback. I've listed some issues/improvements that people can contribute to if they want. I probably won't be able to contribute much myself because I don't have time.
     
  31. Greg-Bassett

    Greg-Bassett

    Joined:
    Jul 28, 2009
    Posts:
    628
    Thanks Justin!!! Good luck with your future projects!
     
    JustInvoke likes this.
  32. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Thank you very much :)
     
  33. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    EDIT : I had a corrupt scene, my performance on mobile was sorted after I created a new scene from scratch
     
    Last edited: May 25, 2017
  34. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The only thing that might be able to improve performance is using Raycast with a cached RaycastHit instance instead of RaycastAll which creates a new array of RaycastHits each frame. I can't promise it will help, but it's the only thing I can think of next to increasing the fixed update timestep, which you probably already tried. Try replacing the first part of the GetWheelContact method in the Wheel script with this (the wheel cast mask on GlobalControl must exclude vehicles for it to work, otherwise the wheel may collide with its own vehicle):
    Code (csharp):
    1.  
    2.         RaycastHit hit;//Make sure this is outside of the method
    3.         void GetWheelContact()
    4.         {
    5.            float castDist = Mathf.Max(suspensionParent.suspensionDistance * Mathf.Max(0.001f, suspensionParent.targetCompression) + actualRadius, 0.001f);
    6.             //RaycastHit[] wheelHits = Physics.RaycastAll(suspensionParent.maxCompressPoint, suspensionParent.springDirection, castDist, GlobalControl.wheelCastMaskStatic);
    7.             int hitIndex = 0;
    8.             bool validHit = false;
    9.             float hitDist = Mathf.Infinity;
    10.            Physics.Raycast(suspensionParent.maxCompressPoint, suspensionParent.springDirection, out hit, castDist, GlobalControl.wheelCastMaskStatic);
    11.  
    12.             if (connected && hit.collider != null)
    13.             {
    14.                 //Loop through raycast hits to find closest one
    15.                 /*for (int i = 0; i < wheelHits.Length; i++)
    16.                 {
    17.                     if (!wheelHits[i].transform.IsChildOf(vp.tr) && wheelHits[i].distance < hitDist)
    18.                     {
    19.                         hitIndex = i;
    20.                         hitDist = wheelHits[i].distance;
    21.                         validHit = true;
    22.                     }
    23.                 }*/
    24.                 hitDist = hit.distance;
    25.                 validHit = true;
    26.             }
    27.             else
    28.             {
    29.                 validHit = false;
    30.             }
    31.  
    32.             //Set contact point variables
    33.             if (validHit)
    34.             {
    35.                 //hit = wheelHits[hitIndex];
    36.                 //Rest of method follows...
    37.  
     
    Meltdown likes this.
  35. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    EDIT : My apologies - The issue was a corrupt Unity scene, not this package.

    After days of battling, and nothing working, I created a new scene from scratch, added all my stuff back, and bang, it went from 9FPS - 40FPS.

    I guess something in my scene was corrupted :(

    Oh well, thanks again, I'm so glad I don't have to overhaul my physics :)
     
    JustInvoke likes this.
  36. Felicityinc

    Felicityinc

    Joined:
    Nov 24, 2016
    Posts:
    24
    Hey @RandomationGames And @CoderPro ,
    Can you guys please share the unitypackage about this drift feature @CoderPro posted earlier.
    Would be appreciated!
     
    Last edited: Jun 11, 2017
  37. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Felicityinc likes this.
  38. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Hi @RandomationGames,
    Could you explain for me why did you using animation curve in the scripts ? And how i can setup correctly animation curve values ?

    Thanks in advanced.
     
  39. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Early on in development animation curves looked like an elegant way to represent data with smooth changing values across a single dimension. There is also the benefit of "infinite resolution" where you can sample at any value along the curve while the curve itself is just a few key values. Over time after the initial release I began to realize how cumbersome working with the curves can be, but at this point they are so ingrained into the package that it would be difficult to replace them while providing a way to copy old curve data into a new system.

    As it stands you have to click on a curve in the inspector to bring up a curve editor window to modify it. You can also modify the keys in curves through scripting, but that is much more difficult. There might be a plugin for easier curve editing and copying/pasting them somewhere if you search, but I don't have a solution.

    If you are asking about optimal curves to set for different components, you're best bet is to reference the prefabs. If you want to know about particular curves I can explain further.
     
  40. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Could you explain further for me ? Its still difficult to set value like you did set for prefabs.
    Thanks in advanced.
     
  41. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Can you be more specific about which curves? There are a lot of different ones.
     
  42. zinkins

    zinkins

    Joined:
    Jun 3, 2015
    Posts:
    21
    Hi, Justin!
    Thanks for amazing asset! It's very good and stable.
    Recently we've found out some strange behavior: when car runs on max speed and player turns on the boost it accelerates a bit from 279 km/h to 288. That's fine. But if player begins to turn a car at boosting on the left or right, the speed will increase a bit more - to 291. So the issue is : when player is just boosting, the speed got one value, when he makes a turn, the speed is higher.
    I've investigating the code of your engine but unfortunately haven't found what causes this issue. Could you please give me some clue how can it be and how to make the speed not increasing on turning?
     
  43. zinkins

    zinkins

    Joined:
    Jun 3, 2015
    Posts:
    21
    Sorry, forgot to write we are using RVP v.2.0.8.1
     
  44. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The small amount of sideways velocity from turning could be triggering the drift pushing if you are using the VehicleAssist script. Try disabling the script or setting "drift push" to zero and see how it works.
     
  45. zinkins

    zinkins

    Joined:
    Jun 3, 2015
    Posts:
    21
    Yes, I tried disabling this script but with no luck
     
  46. Lesnikus

    Lesnikus

    Joined:
    Aug 29, 2015
    Posts:
    47
    Hello! Why does the error occur when I write my AI script?

    Invalid AABB result

    transform.position assign attempt for 'Muscle Car (2)'s Normal Orientation' is not valid. Input position is { NaN, NaN, NaN }.
    UnityEngine.Transform:set_position(Vector3)
    RVP.VehicleParent:FixedUpdate() (at Assets/Scripts/Vehicle Control/VehicleParent.cs:231)

    Assertion failed on expression: 'curveT >= GetRange().first && curveT <= GetRange().second'
    UnityEngine.AnimationCurve:Evaluate(Single)
    RVP.SteeringControl:FixedUpdate() (at Assets/Scripts/Vehicle Control/SteeringControl.cs:43)

    Assertion failed on expression: 'curveT >= m_Curve[lhs].time && curveT <= m_Curve[rhs].time'
    UnityEngine.AnimationCurve:Evaluate(Single)
    RVP.SteeringControl:FixedUpdate() (at Assets/Scripts/Vehicle Control/SteeringControl.cs:43)

    (further many similar errors related with curveT)

    rigidbody.force assign attempt for 'Muscle Car (2)' is not valid. Input force is { NaN, NaN, NaN }.
    UnityEngine.Rigidbody:AddForceAtPosition(Vector3, Vector3, ForceMode)
    RVP.Suspension:ApplySuspensionForce() (at Assets/Scripts/Suspension/Suspension.cs:289)
    RVP.Suspension:FixedUpdate() (at Assets/Scripts/Suspension/Suspension.cs:221)

    transform.position assign attempt for 'rim' is not valid. Input position is { NaN, NaN, NaN }.
    UnityEngine.Transform:set_position(Vector3)
    RVP.Wheel:positionWheel() (at Assets/Scripts/Drivetrain/Wheel.cs:657)
    RVP.Wheel:FixedUpdate() (at Assets/Scripts/Drivetrain/Wheel.cs:328)

    transform.position assign attempt for 'Rim Collider' is not valid. Input position is { NaN, NaN, NaN }.
    UnityEngine.Transform:set_position(Vector3)
    RVP.Wheel:positionWheel() (at Assets/Scripts/Drivetrain/Wheel.cs:665)
    RVP.Wheel:FixedUpdate() (at Assets/Scripts/Drivetrain/Wheel.cs:328)

    Further, a huge number of errors, where different variables have { NaN, NaN, NaN } and Invalid AABB
    And the editor freeze or crashes
     
    Last edited: Oct 27, 2017
  47. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The PDF manual has a section showing required project settings, everything not mentioned can be adjusted freely.

    I don't know exactly what could be causing the problem, sorry. I know it doesn't help much, but if the speeding up issue is caused by boosting while turning then the source of the problem is probably either in the engine or wheels where the friction is applied to drive the vehicle.

    So this is a custom AI script? There is probably a division by zero somewhere resulting from however the curves are configured. You will want to start with the first error that appears in the console, so I assume the problem stems from VehicleParent or SteeringControl.
     
  48. Lesnikus

    Lesnikus

    Joined:
    Aug 29, 2015
    Posts:
    47
    Why AI is calculated in FixedUpdate? If it is calculate in the "void Update", it will less load the processor. The "FollowAI" script is small, but if it is expanded, it can give a lot of work to the processor. Is there any serious reason to calculate AI in FixedUpdate, and not in Update?
     
  49. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The only reason it uses FixedUpdate is because that way the AI can react more readily to changes in the physics engine. You can probably change it to Update, just make sure to change the line where reverseTime is decreased to use delta time instead.
     
  50. stormAster720

    stormAster720

    Joined:
    Mar 18, 2015
    Posts:
    4
    hi Randomation games

    i have the Randomation Physics 2.9 and I create an rpm meter with needle that is working but i want to create a rpm meter with numbers, what i should do?

    here is a image of mi rpm meter

    Note:Im from colombia, sorry for my english




    upload_2017-11-24_0-0-45.png
     

    Attached Files: