Search Unity

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

Randomation Vehicle Physics 2.0 - Now open source on GitHub!

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

  1. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    406
    here you go

     
  2. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    That's most likely the mesh collider, sometimes they're finicky like that. One thing that could help is lowering the default contact offset in the physics settings. I'll work on improving the hovering forces so hovering vehicles won't scrape on the ground as easily.
     
  3. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    can someone help, i cant figure out how to change the car speed, is there a easy way to change it without complex math
     
  4. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    In the section of the manual titled "Changing Performance" you will find the formula for top speed:

    max RPM of engine / last gear ratio of transmission / (Pi * 100) * circumference of driven wheels


    This means that the engine, transmission, and wheel radius are the biggest factors affecting speed. The torque curve of the engine represents the engine's torque output at different RPMs, the rightmost key on the curve is the maximum RPM x 1000. The transmission's ratios modify the speed and torque output based on their ratio, 1 = Unchanged RPM and torque, greater than 1 means more torque but lower RPM, and less than 1 means less torque but greater RPM.

    The math isn't that complicated, just some multiplication and division. (Circumference of wheel = 2 x Pi x radius.)
     
  5. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    thank you :)
    in a future update is it possible to add a slider for speed, lol
     
  6. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    That's an interesting idea, maybe it's possible to add some kind of slider that automatically adjusts the properties of engines and transmissions. It turns out I can write editor scripts now, so I can improve the workflow a bit. In the past when I tried to write editor scripts, they would not be able to differentiate between the C# and JS versions of classes and throw some sort of ambiguous reference exception. Now that problem seems to be gone.
     
  7. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Yeah like a slider for traction for front wheels and back wheels for slick tracts, mud or ice etc.
     
  8. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    There are already friction variables on the wheels you can adjust, and scripts for adjusting surface friction. Read about GroundSurfaceMaster and GroundSurfaceInstance in the manual for more info.
     
  9. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Can you set friction differently for the front wheels and back wheels?
     
  10. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    can every one post speed parameters that work, i'm sure this shared information would be helpful to everyone.
    example : engine = XXXX RPM= XXXX to get top speed of 120MPH

    i'm going to take the day off my day job to figure this out :)
    and if i do i will post my results
     
  11. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    I have another question regarding the damage model of a car. or about the muscle car prefab.
    how did you set that beast up? i mean there are... maybe 50 parts? :D and each of them has this detachable part script on it with custom settings and joint settings and so on. is there something similar to the build in unity ragdoll wizard just for cars?
    or do you have any best practice to share? :)
     
  12. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    well........sadly i took the day off my day job , and... still cant get the speed change to work......... guess i shouldent quit my day job anytime soon, lol
     
  13. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Yes, adjust the friction variables on the wheel objects in each vehicle.
    I still have to take some time to figure out if the speed slider is practical.
    The muscle car is an extreme example of a damageable vehicle meant for demonstrating the functionality. Most vehicles you make will probably be simpler.

    You can start by having your vehicle modeled with all detachable parts as separate meshes, make sure their origins are near their centers and not the center of the whole vehicle. Add all of the meshes to the deform meshes array on the VehicleDamage script.

    Next you need to have colliders for different parts of the vehicle. Colliders should not deform as it's expensive to do so. Since colliders can't deform they must be displaced instead, so you need to have enough of them on the vehicle to closely match the deformed visual meshes as they change shape. For example, the hood of a vehicle could have 4 box colliders arranged in a grid shape, each one representing a quarter of the hood. When the hood deforms, the colliders will be moved to match the deformation. Make sure to add the colliders to the displace parts array of the VehicleDamage script. More colliders will give a more accurate representation of the visual meshes.

    I have some ideas for changes to improve productivity and I want to add a simpler damageable car since the muscle car is a bit overwhelming. Maybe I can make some sort of wizard for easy setups.
     
  14. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    okay, thank you verry much, that cleared a lot of stuff.
    i saw that you have a pretty easy car here:

    do you mind sharing this? since i think thats easier as a base :)
     
  15. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Sure, I think I can bring it back.
     
    Der_Kevin likes this.
  16. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    46
    hi ... I have bought randomation physics vehicle 2.0. i do not understand how can i apply this physcis on my simple car which have only 4 tyres and one body of my car ... i have read all your manual, you guys have just write details of things but do not tell anyone how to implement this physics on any vehicle.
     
  17. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    For starters, try using one of the demo vehicle prefabs.
    Once you've got the prefab you want, and the GlobalControl prefab into your scene, you'll see that the car goes like normal. To change things like the body and the wheels, simply replace the body that is in there now with your custom one, and same with your rims, tires etc.
     
  18. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    46
    thanks for reply @WOODSY What if i have't rim and other parts. I have already told you that i have only tyres and car body nothing else. I do not want any demage effect i just want car physics (movement). i want detail and a demo to do that ...
    your help is very appreciated.
     
  19. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Near the start of the manual there are some sections dedicated to setting up scenes and vehicles, one thing I forgot to add is that you can delete the tire objects from your vehicle if you don't want them. Then you can have the rim objects use the mesh containing both the tire and rim. I'm going to work on some editor scripts for the next update to make things easier.
     
  20. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    46
    @RandomationGames i have a problem the boost is not increasing the speed. just particle effects are shown at the end of the car but the speed behaviour is remain same. your help will highly appreciable. bundle of thanks
     
    Last edited: Sep 5, 2015
  21. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Have you adjusted the boost power curve on the engine of the vehicle? Boosting only works when the accelerator is also pressed.
     
  22. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    I agree. This would make RVP2 much more user friendly. Simple sliders for things like "Top Speed", "Acceleration", and "Control" that automatically adjust other variables would be great. Currently it takes a lot of trial and error to get the effects you want.
     
  23. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    hi !!!!!
    i would like to know if is possible to replicate this old fashing drift way


    thank you
     
  24. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    A physics package like mine is overkill for a game like this and while it is possible to achieve fairly arcadey drifting, it's not practical to get the hyper-predictable easy drifting of a kart racer. Kart racers also depend on vehicles not flipping over, which is impossible to completely avoid even though vehicles can be tweaked to be mostly resistant to it.

    I prototyped some kart physics earlier this summer, and what seemed to work well was letting the physics engine handle the movement, but locking the rotation of the rigidbody and manually rotating the transform. I used the ground normal in combination with the projection of the forward direction onto the ground plane to set rotation.
     
    angelodelvecchio likes this.
  25. chrisabranch

    chrisabranch

    Joined:
    Aug 15, 2014
    Posts:
    146
    I love how you respond to everyone, very good support keep it up :)
     
  26. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    The support is awesome!
     
  27. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    46
    how adjust the boost power curve. What i have to do with this curve ??
     
  28. angelodelvecchio

    angelodelvecchio

    Joined:
    Nov 15, 2012
    Posts:
    170
    This asset worth every penny
     
    HakJak likes this.
  29. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Thanks for your kind words everyone.

    From the manual:

    Boost power curve – Percentage of how much the motor's RPM and torque is increased while
    boosting. X-axis = local z-velocity of vehicle, y-axis = power.

    Basically it affects how powerful the boost is at different speeds, it used to be a number but that was too limiting.
     
  30. danish115

    danish115

    Joined:
    Aug 28, 2014
    Posts:
    46
    thanks @RandomationGames i want to make car customization scene in wich acceleration and top speed increases after purchasing these items how can I increase the acceleration and top speed of special car ??
     
  31. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Please read the section of the manual titled "Changing Performance". The engine power/torque, transmission ratios, and tire friction affect acceleration, while the engine's max RPM, transmission ratios, and wheel radius affect top speed. In the case of continuous transmissions like on the special car, increasing the min ratio variable will increase acceleration, but I just realized that increasing it too much causes the automatic shifting to fail. I will try to fix this.

    Further up on this same page I already answered a question regarding top speed. I'm going to work on some editor scripts to make things easier.
     
  32. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Okay, so I really like having the RPM and speedo on the UI, but I'm having some real trouble trying to set up just the speedo and RPM, nothing else. But I can't seem to get it to work, even after editing the script.
     
  33. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Have you deleted or deactivated the unwanted UI elements? If you delete them you just need to add some null checks to the VehicleMenu script.
     
  34. TymNetwork

    TymNetwork

    Joined:
    Jan 16, 2014
    Posts:
    82
    I would like to make the Semi Truck Chase me for a video demo I am making.
    Do I just add the AI script of the chase vehicle prefab to the semi and make it a chase vehicle on button push?

    Not sure. Thanks. Love the upgrade. Wish the monocylce and motorcycle were able to be re-made. Peace.
     
  35. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    You can copy the FollowAI script to the truck, just make sure the target is set to the vehicle it should chase. Remove the BasicInput script from the truck so the player can't control it.
     
  36. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Okay, to get the overall RPM from the vehicle and show that data through a slider, what element would I have to use? The DriveForce from the wheels or engine?
     
  37. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    The feedbackRPM variable on the engine's DriveForce is what should be used for an RPM meter. You might want to clamp it since it can be zero.
     
  38. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Awesome! Cheers for that
     
  39. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Oh and just one thing, I'm trying to really get away from the demo scripts because they don't really suit my type of game (camera type etc.) but is there a way I can get the float value from the feedbacRPM and input that data straight to a slider?
    Thanks so much
     
  40. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    You have to write some code to do so, something like this for the slider:
    Code (csharp):
    1.  
    2. public DriveForce drive;
    3. public Slider meter;
    4.  
    5. void Update()
    6. {
    7.      meter.value = (drive.feedbackRPM * 0.001f) / drive.curve.keys[torqueCurve.length - 1].time;
    8. }
    9.  
    The slider's value will be normalized between 0 and 1.
     
  41. hamyshank

    hamyshank

    Joined:
    Jan 31, 2013
    Posts:
    88
    Has anyone else had any trouble with using custom suspension parts and them not lining up?

    Im using blender to create the models, and I know about the rotation issues. But I've tried many different rotations and I just cant figure it out. Any help would be appreciated. :)
     

    Attached Files:

    • SS1.png
      SS1.png
      File size:
      312.5 KB
      Views:
      866
    • SS2.png
      SS2.png
      File size:
      345.1 KB
      Views:
      776
  42. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    Suspension parts point along their local forward direction (blue z-axis). Make sure when you apply rotation in Blender that the object is oriented as such. Up in the top left of the Unity editor where it says "Global", you can click it to change to "Local" and see which way the local axes point.
     
    hamyshank likes this.
  43. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    do you have an idea when the "make things easier" update is done? :)
     
  44. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    374
    At least a few weeks.
     
    Der_Kevin likes this.
  45. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Wow thank you so much! I really appreciate it!
     
  46. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Heres a little video of my current game, Project Wheels

     
    JustInvoke likes this.
  47. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Okay, here I've got a basic script for all of you who don't really like/use the built in vehicle menu.

    This is the script I used for the HUD in my game above

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using UnityEngine.UI;
    4.  
    5. public class CarStats : MonoBehaviour
    6. {
    7.     public VehicleParent vp;
    8.     public Text speedText;
    9.     public DriveForce drive;
    10.     public Slider meter;
    11.     public Text gearText;
    12.     public GearboxTransmission gearbox;
    13.  
    14.     void Update()
    15.     {
    16.         meter.value = (drive.feedbackRPM * 0.001f);
    17.  
    18.         gearText.text = (gearbox.currentGear == 0 ? "R" : (gearbox.currentGear == 1 ? "N" : (gearbox.currentGear - 1).ToString()));
    19.  
    20.         speedText.text = (vp.velMag * 3.6f).ToString("0");
    21.     }
    22. }
     
  48. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    406
    Good job WOODSY...

    I've been playing around with a Rocket League inspired prototype using this.

     
    JustInvoke likes this.
  49. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Nice! Looks really good!

    Also you can try the current version here http://gamejolt.com/games/project-wheels/90145
     
    Last edited: Sep 25, 2015
  50. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,797
    Brakes only seem to work correctly when brake force is set to 0.5. I had it set to 1 and it wasn't working. I tried 0.9 and it still didn't work.

    The visual indication of the tyres is accurate, so on 1, the tyres stop spinning totally, and it looks like they are braking, but the car just carries on. Definately something buggy there...