Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    Hi.

    New user here. I'm having some difficulty figuring out how to set up our own vehicle models, the example car prefabs seem to have a very specific breakdown of meshes and collision parts, not sure which are needed. A video walkthrough explaining how to set up a third party vehicle from the asset store would help, I'm sure.
     
    Der_Kevin likes this.
  2. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,490
    Did you read the manual? It has a specific section setting up your own vehicle.
     
  3. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    Yes, I have been looking at that carefully, and it is helpful but it still seemed to raise a bunch of questions. Like it mentions that the rim meshes need to be oriented in a particular way, but do the suspension objects and wheel objects they are parented to need to be oriented in a particular way too, would that affect the axis of suspension? Are separate tyre meshes from rim meshes recommended for some reason? What's the advantage of separating collision meshes into front, mid, rear, and underneath, and what is a suggested workflow for generating these separate collision volumes. I just thought that as it seems the process of preparing a vehicle is quite involved and there may be multiple ways to go wrong, it might be useful watching how someone might approach setting up a third party vehicle, rather than something specifically prepared for this in a modelling program.
     
  4. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    507
    Agree with dencil, a video tutorial is always better than a wall of text. Or even a car wizard that helps you in some way.
    I usually just replace the body of one of the example cars. since setting a car up from scratch is a pain in the ass. Still haven't tried to make a destructable car with different parts. thats another chapter.

    by the way, is this thing still "on"? haven't heard from RandomationGames in this thread in a while and people seam to helping each other
     
  5. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    I'd rather see 2 wheel support over Randomation wasting time on videos about stuff already covered in the excellent manual.
     
  6. john-essy

    john-essy

    Joined:
    Apr 17, 2011
    Posts:
    464
    Fixed the problem, it is 2 pages before this that he offers a solution and worked great for me.

    EDIT : Turns out it's on this page.

    After some tests, it seems that setting the inertia tensor to equal itself fixes the problem. Try adding this after line 367 in the VehicleParent script, where the center of mass is set. The line count obviously varies if you've modified it, and it's in the SetCenterOfMass() method.
    Code (csharp):
    1. rb.inertiaTensor = rb.inertiaTensor;
    This strange solution makes me wary of what else might be broken, since it doesn't seem like intended behavior for the act of simply setting the variable to cause it behave so differently. I'm going to file a bug report and see what Unity has to say, I don't want to rush out a hotfix just yet.
     
  7. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    507
    isnt there a motorcycle now?
     
  8. Obsurveyor

    Obsurveyor

    Joined:
    Nov 22, 2012
    Posts:
    277
    Oh wow it got snuck in an update as a prefab and I missed it! Seems to work pretty well too(had to add it to the menu myself), though a little jittery.
     
  9. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    I've struggled through setting up one of our vehicles, now I'm trying to get its feel right. Our game play calls for jumps (and airborne tricks), and I'm finding often that when landing from even small jumps, if I'm steering at the time of the land, I'll go into a 180º spin. I'm not sure what might cause that. I can prepare a small example project if Randomation is able to look at it.
     
  10. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    I apologize for my absence, for some reason I stopped receiving e-mail notifications about new replies, and I've been very busy with other things so I forgot to manually check the forums. I will make sure to come back here occasionally since I can't depend on the e-mail notifications anymore.

    @Meltdown, with your boost issue, you can try increasing the feedback RPM bias of the wheels. When wheels lose grip due to excessive torque, the transmission tends to upshift to compensate, which leads to the "turning over" sound you describe.

    The suspension and wheel objects should be rotated in local space as they are in the prefabs, with their local z-direction facing out towards the side of the vehicle they're on and the local y-direction pointing up towards the vehicle's roof. Visual suspension parts (ones meant to move) will point their local z-direction where they are configured to based on the SuspensionPart script.

    Tire meshes only need to be separate from the wheel meshes if you want the tires to pop, otherwise the rim object can contain the entire wheel's mesh, and you can either delete or deactivate the tire object.

    Separate collision meshes aren't required, but it's generally a good idea to have a separate one on the underside with less friction, and to not count with crash detection. The reason some vehicles have separate ones for front, mid, and rear are because of the nature of convex colliders, where if there was only one for the whole vehicle, it would fill in the areas between the windshield and hood, and the back window and trunk. Currently, the only way to make these is to model them yourself.

    @Obsurveyor, I have tried several times to implement bike physics, but there are kinks I haven't been able to iron out. I might try again in the future. The bike prefab is always been there, and the VehicleBalance script is documented at the end of the manual. I chose not to advertise the bike as a feature because it doesn't work so well.

    I also got your e-mail about this, that's actually what prompted me to come back here since you said you had also posted here, but I didn't get a notification. I would appreciate it if you could send the project, since I haven't experienced this kind of behavior. I will post the solution here though in case others have the same issue.
     
    Meltdown likes this.
  11. gabaodesign

    gabaodesign

    Joined:
    Nov 16, 2015
    Posts:
    2
    Hello, excuse me for my english. i have bought your asset but i can use it, because when i creat new car wheel dont have any effect with floor
     
  12. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Does the wheel cast mask on the GlobalControl object include layers that wheels should collide with?
     
  13. gabaodesign

    gabaodesign

    Joined:
    Nov 16, 2015
    Posts:
    2
    Hello, my probleme when i start the game wheel dont have effects with floor. the same thing with the prefab car of randomation problem.jpg
     
  14. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Does this happen in the included demo scene? Have you verified that the wheel cast mask on the GlobalControl object is set correctly? If the wheel cast mask is not set properly, wheels will not detect certain objects.
     
  15. john-essy

    john-essy

    Joined:
    Apr 17, 2011
    Posts:
    464
    I don't know if someone can help me out with something, I am 100% sure my brain is farting here.

    I'm currently on the last stage of vehicle customisation which is actual vehicle stats, For some reason i cannot find / fatham which values to change. I need to change vehicle Speed, Braking, Handling, and weight but again brain is farting right now.

    Any help / guidance on where to find these little S***s would be appreciated. What makes this worse is i have done this before multiple times :(
     
  16. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Vehicle speed can be adjusted by the length of the torque curve on the engine and the ratios of the transmission gears. Braking is handled by the brake variables on the suspensions. Steering is affected by the steer variables on the suspensions and the steering wheel object. Weight is the mass of the rigidbody on the root transform.
     
    HakJak likes this.
  17. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    179
    I'm having some difficulty understanding the "normals curve." How should I set it to allow vehicles to climb steep angles more easily?
     
  18. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Basically, move the key on the left side of the curve up higher. 0 on the x-axis is for a completely sheer surface, like a wall, and 1 is for flat ground. The y-axis is the friction applied based on the steepness. You will have to zoom out a bit in the curve editor because the default curve is a flat line and the view will be zoomed in on the y-axis.
     
    HakJak likes this.
  19. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    179
    Thank you! That was a super easy change and easy to tweak to get exactly the effect I want.
     
  20. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    I'm actually in the opposite boat to HakJak, I'd like to prevent my vehicles from climbing very steep cliffs. I tried editing that curve so that the first half of the normal (ie from sheer walls to 45º slopes) produces 0 friction, and then from 0.5 to 1 in x produces a friction constant of 1. But I'm still getting behaviour where the vehicle hits a steep cliff head on, and scales it, thanks to the momentum they had already.

    I saw that downforce is applied in relative Y, so thought that might be keeping the vehicle clinging to cliffs, but removing that didnt seem to help. What I'd like is that a sudden contact with a wall whose normal opposes that of the wheels current velocity would cause a crash or bounce. Any tips for getting that?
     
  21. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Maybe you can increase the friction of both the wall and vehicle colliders so that the vehicle will catch on it instead of sliding straight up it.
     
  22. rolliefingez

    rolliefingez

    Joined:
    Apr 4, 2013
    Posts:
    23
    probably a super stupid question but Im trying to setup steer right / left mobile buttons, accel and brake work fine, steer not so.

    I have setup MobileInput.SetSteer for each button and also disabled accelerometer steering?

    upload_2016-3-23_1-1-11.png
     
  23. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    Sorry I'm confused. Didnt you suggest to HakJak he increase friction (in his case via the Y axis on the normal curve) to allow him to climb steep curves more easily. Now you say increasing friction on the materials will help me prevent the same?

    Anyway, it doesnt seem to help. For some reason the wheels are colliding with the steep wall in front first and the vehicle is reorientating, even though I've extended the body collision further in front of the wheels. Do the wheels take into acount the Physic material properties they contact?
     
  24. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    This is probably because each button sets it back to zero when released, and it could be overriding the opposite button pressing down. You might have to pass the button's input values into another script that chooses the strongest one and then sends that to the MobileInput script. There is even a static MaxAbs function in the F script you can use that returns the number with the greatest absolute value from a set of numbers. Something like F.MaxAbs(leftButtonInput, rightButtonInput) could work.
    I was talking about the friction on the physic materials of the colliders, since I figured that would prevent vehicles from sliding up steep slopes upon collision. The wheels only take into account the physic material friction if there is a Ground Surface Instance attached to the collider and the surface type has "use collider friction" set to true. If you are still having issues, I would appreciate seeing a video of the problem to better understand what is happening.
     
  25. rolliefingez

    rolliefingez

    Joined:
    Apr 4, 2013
    Posts:
    23
    thanks for the quick response, Ill give it a whirl cheers....

    Just glad I wasnt being too stupid!
     
  26. duencil

    duencil

    Joined:
    Dec 17, 2012
    Posts:
    91
    I havent set a Ground Surface Instance to the surface, but then again its a terrain collider. I suppose I'd need a way to establish multiple Physic Materials or Ground Surfaces on a terrain based on its terrain splatmap, and then also use a different texture for the cliffs than the ground in order to get different friction properties.

    I've tried adding larger collision boxes to the vehicle, even attaching one to the top half of each wheel, and if I set the Physic Material type on those collision boxes to "None" rather than "Car Body", I can somewhat prevent scaling cliff walls, but not consistently enough to be satisfactory. On thing I noticed, if its of any use, is that the Rim Colliders created at runtime for each wheel have a tiny radius, much smaller than the wheel, and not likely to collide with anything. I'm not sure if that is significant, and if so if it points to a problem with my model setup.

    Here's a video anyway to see what I'm talking about.

     
  27. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    There is already a TerrainSurface script you can use for terrains. The rim colliders are supposed to be small so they don't stick out from the side of wheels, so they are limited to the width of each wheel.

    Maybe you could place invisible walls around the edge of the map? It's pretty much the only way to prevent players from scaling walls when driving at high speed into them.
     
  28. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    314
    I think have a bug that maybe author not see that. When i drift car, sometime car move too fast that > max speed. I don't known why. Maybe @RandomationGames should test and review this issue.
     
  29. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    It's probably the drift push variable on the VehicleAssist script. This is meant to accelerate the vehicle when drifting, but it doesn't cap itself when the vehicle reaches maximum speed because accurately calculating the top speed is complicated. The top speed shown on engines is only an estimate. I probably should have designed the system from the start to have an option for manually setting a top speed and having the vehicle automatically adjust its variables to accommodate it.
     
  30. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Version 2.08.3 has been released with the following changes:

    Wheel – New “friction smoothness” variable to adjust how smoothly the applied friction forces change. Increasing this can reduce vehicle jitter/shaking.

    GasMotor – Boost properly increases top speed.

    HoverMotor – Boost properly increases top speed.

    The price has been permanently lowered to $39 USD. It might decrease again near the end of the asset's life, but I plan to at least support it through the remainder of Unity 5.x.
     
  31. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Is this starting to hint towards RVP 3? Because count me in!
     
  32. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    No, actually the opposite. I want to stop selling it when Unity 5 ends and move on from asset sales/support. However I don't know anything about the duration of Unity 5, I'm just making assumptions based on the roughly 2 year lifespan of each major version.

    I will still support it fully until the end and gradually improve it over time as I have been over the past year.
     
  33. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Awesome! It's been an awesome asset to use!
     
  34. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,050
    Hey, is it possible to have no suspension/shocks on the wheels? I'm trying to make a semi realistic kart and they do not have suspension/shocks and just rely on their tires. Cheers
     
  35. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    179
    You can change the spring strength almost all the way down... but that's the closest I've come without creating unexpected behaviors.
     
  36. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    You can get fairly close by setting the suspension distance or spring force to zero, then lowering the hard contact force if the vehicle starts jumping around. The tires might still clip into the ground since the suspension/wheel physics are based around AddForce and not solid colliders.
     
  37. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,050
    OK, thanks. I'll play round with those settings & see how I get on.
     
  38. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,050
    So far so good, still need to play around with the settings more.
     
    JustInvoke likes this.
  39. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,050
    Hmm, I'm having an issue with the left side wheels going through the ground but the right side are fine. Any thoughts?
     
  40. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Maybe the suspensions on one side are rotated incorrectly, make sure their forward direction points out from the side of the car and the up direction points up from the roof.
     
  41. Indie1

    Indie1

    Joined:
    Aug 22, 2014
    Posts:
    10
    Has anyone tried to actually make a multiplayer mode using this vehicle kit and Photon multiplayer?
     
  42. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    I haven't tried it but someone on the first page claims it works well.
     
  43. uprashanth

    uprashanth

    Joined:
    May 24, 2014
    Posts:
    99
    Any one interested in playmaker actions for this asset ? I'm currently making one.
     
  44. Xenobite

    Xenobite

    Joined:
    Jan 27, 2014
    Posts:
    15
    I am :)
     
  45. uprashanth

    uprashanth

    Joined:
    May 24, 2014
    Posts:
    99
    I will update u, maybe I will finish in 3 days. Will be available on asset store for $25. Comes with 200 - 300 actions.
     
  46. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    314
    Hi @RandomationGames Could you add Top Speed feature to limit speed of car ? Thanks
     
  47. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    Do you mean like a sort of hard limit that forces it to stay under a certain speed?
     
  48. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    314
    Yes. With the current version, i can not set max speed for AI car. Could you add a top speed feature to limit speed of car ? Thanks
     
  49. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    340
    There is a speed variable on the FollowAI script but it basically acts as a multiplier for the top speed. For some reason it is currently forced to be equal to the starting value in each step, so I'm removing that restriction. I could add a target velocity option instead but it would be in meters per second since that is generally the measurement used for rigidbody velocity.
     
  50. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    314
    I hope you will add this variable for the next update. Thanks you
     
unityunity