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

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    The two scenarios are caused mainly by adjusting the dampening. So the second scenario becomes the first when I increase the dampening, and vice versa.
     
  2. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Have you adjusted the spring force curve and spring exponent, or disabled the hard contact force?

    It's pretty difficult to make tweaks like this through forum posts, do you have a Skype we could use to communicate more readily? Either that or maybe you could provide a stripped-down project for me to work with.
     
  3. VirtualisDev

    VirtualisDev

    Joined:
    Jul 21, 2015
    Posts:
    30
    Hello,


    I would like the car to decelerate when accelerator is not pressed, like a real driving where, when you don't press the accelerator, the vehicle's speed quickly decrease.

    What parameters mus i check to do that ?
     
  4. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Increase the drag of the rigidbody, by default all of the vehicles have zero drag and will roll forever. There is also no friction in the drivetrain.
     
  5. VirtualisDev

    VirtualisDev

    Joined:
    Jul 21, 2015
    Posts:
    30
    Thanks,

    It's working better with some drag but where can i find the drivetrain parameter ?
     
  6. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The drivetrain refers to the path of the drive through transmission and suspension. In a real vehicle there is always friction within this system, but not in my physics. I may add it in since you're not the first to ask about this.
     
  7. VirtualisDev

    VirtualisDev

    Joined:
    Jul 21, 2015
    Posts:
    30
    O.k, thanks.

    Is there a simple way to increase the max speed or do i have to check multiple parameters ?
     
  8. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The maximum speed is based on the engine's RPM's, transmission ratios, and and wheel circumference. Look at the section titled "Changing Performance" in the manual for a detailed explanation.
     
    Last edited: Aug 6, 2015
  9. trhero

    trhero

    Joined:
    Mar 6, 2014
    Posts:
    7
    is it working with photon network?
     
  10. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
  11. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    Any gameObject will 'work' with Photon as all Photon really does it send values about the GameObject such as position and rotation etc. However if you're looking for a Unity physics aware authoritative solution that will work with Randomation take a look at uLink.
     
  12. WaqarKhan703

    WaqarKhan703

    Joined:
    Sep 9, 2013
    Posts:
    7
    Hello Randomation Games,

    I'm having some understanding issue. I've noticed that on every car there is a script named vehicle parent , it has OnCollisionEnter and OnCollistionStay and they're detecting collision well. My question is that I didn't find any Collider component on any car main gameObject. Although, There are some convex mesh colliders in the children(Mid, front, rear, under). I want to use OnTriggerEnter(). How can I use it.

    How is it getting collisions when there's no collider component on main gameobject. I'm sorry if question is dumb. Please help me out on this
     
  13. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    All children with colliders attached are referred to as compound colliders, so any child objects with colliders are accounted for during OnCollisionEnter and OnTriggerEnter as being part of the parent rigidbody.

    You can use OnTiggerEnter(collider) as you would with any other rigidbody. The collider parameter of the function is the trigger that the rigidbody intersects with. Try doing something like this for a test in the VehicleParent script:
    C#
    Code (csharp):
    1.  
    2. void OnTriggerEnter(Collider trig)
    3. {
    4.      print(trig.name);
    5. }
    6.  
    JS
    Code (csharp):
    1.  
    2. function OnTriggerEnter(trig : Collider)
    3. {
    4.      print(trig.name);
    5. }
    6.  
     
    WaqarKhan703 likes this.
  14. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    I noticed that as well. Same thing happens when you drive through mud or ice. The vehicle is reacting correctly by having less friction, but the wheels aren't "slip-spinning" like they should be.
     
  15. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    I submitted a new update for approval yesterday containing a fix for Meltdown's problem. It was because of the way feedback RPM was sent to the engine from the transmission and how it was interpreted by the engine.

    The issue with wheels not spinning on slippery surfaces can be addressed with the RPM bias curve and feedback RPM bias variable, plus a new one coming in the next update. Raise the left key of the RPM bias curve to somewhere between 0.1 and 0.2, and increase the feedback RPM bias to at least 0.5 to prevent automatic transmissions from upshifting prematurely. The new variable coming the update will act as a limit for the RPM bias curve, so its effect is decreased at higher RPMs since it can cause wheels to spin too much.
     
    Meltdown likes this.
  16. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    I've tweaked all those things, for many many hours, and can't find something I'm happy with. I'll put together a small repro project in the next few days and PM you with skype details.
     
  17. woodsynzl

    woodsynzl

    Joined:
    Apr 8, 2015
    Posts:
    156
    Okay, is there a way to set up a basic slider with the mobile input script on the vehicle?
     
  18. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    I'm having a problem with the brakes.

    Brakes don't even work at stopping the vehicle. I tried setting brake force to 1, and even 20, and while the wheel stops spinning, my vehicle keeps sliding on forever and not losing any momentum. I'm on a fairly grippy surface, and wheel forward friction is between 6 and even up to 18.

    The traction gained from spinning wheels forward, in relation to braking seems way off.
     
  19. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Do you mean a UI slider for steering or acceleration? As long as you can get the value from the slider into the SetAccel, SetBrake, or SetSteer functions of VehicleParent it should be possible.
    Do the brakes work adequately on the template vehicles for you? I just tested them and they seemed to work fine.

    The slip and friction calculations are exactly the same between braking and acceleration.
     
  20. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    Hey, i just bought your Asset and its totally fun to play around with it!

    what i am looking for now is, a value to see how much damage the car already has? i mean there is already some damage visualization going on but can i somehow check total damage of the car?
    i wanted to add a health bar to the car, thats why iam asking
     
  21. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    The motors and transmissions already have a health variable with a range of 0 to 1. When the motor's health is zero, it stops working, and when the transmission's health is at zero, it stops shifting.

    The damage of other parts of the car isn't as easy to quantify, since wheels can be offset based on collision force but still be driveable until detached or jammed. It depends on what factors should count when creating a health bar for the entire car.

    Using the motor's health as a multiplier for the health equation would be ideal, since the vehicle depends on it to drive. To measure the health a wheel, maybe you could get the dot product between its suspension's current and original local forward directions, since the offset of the suspension greatly affects driveability. When a wheel is detached or jammed you could take away 25% of the total health of the vehicle, assuming there are 4 wheels on it.
     
  22. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Randomation Vehicle Physics 2.06 has been released with the following changes:

    Replaced instances of F.PowNatural() with Mathf.Pow() as it was discovered to be slower. The function is still available in the F script in case users wrote scripts making use of it.

    Transmission – Changes to feedback RPM to fix issue with lack of torque when vehicle is rolling quickly one direction while trying to drive opposite way.

    GasMotor - Changes to feedback RPM interpretation because of changes to Transmission.

    Wheel - New “axle friction” variable for slowing down coasting vehicles.

    Removed new RaycastHit() declaration from GetWheelContact() function for reduced garbage collection.

    Changed case of first letter of “rpmBiasCurve” to lowercase to match other variables. Curves on vehicles may be reset to default because of this.

    New “RPM bias curve limit” variable for finer control over output RPM based on the RPM bias curve.
     
    Meltdown likes this.
  23. vencl0vs

    vencl0vs

    Joined:
    Feb 20, 2013
    Posts:
    9
    Hey,

    Is it working on webgl export? Any demo scenes to test webgl export?
     
  24. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    I just tried it and I get some errors relating to not being able to run il2cpp.exe, but I have no idea what to about it. I'm not familiar with WebGL yet. Googling shows that some other people have the same problem.
     
  25. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    yes, thanks for the hint. i found the value. (engine>damage>strength)
    i just have a problem - i can do whatever i want, the motor does not get destroyed, i do flips, drive against walls with full speed but that does not really impress the engine/motor.

    I used the short car prefab by the way
     
  26. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Only the muscle car is set up to be damaged by default.

    To set up damage on the short car, add the VehicleDamage script to the car itself, then drag the engine object to the damage parts array. Make sure to move the engine object to where the engine actually would be in the car since the damage is based on how close it is to the collision point. Reduce the strength variable on both the VehicleDamage script and the engine otherwise it will be invincible.
     
  27. Der_Kevin

    Der_Kevin

    Joined:
    Jan 2, 2013
    Posts:
    517
    ah, cool thanks, found it :) but where do is see the value of the motor health from the muscle car?
    can i find it somewhere in the inspector to debug it? i thought it would be the strength value in the gas motor script but my car is broken now but it still has a strenght of 0.5 :D
    i see that there is a heals float in the motor.cs but the muscle car is using the gasmotor.cs?

    did i already mentioned that it is too much fun playing around with it? :D
     
    Last edited: Aug 20, 2015
    HakJak likes this.
  28. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Having a problem that seems like it should be pretty easy to solve, but I'm stumped. Hoping someone on this forum can help me out. I can use RVP 2 to create different particle effects for the tires on different materials... but how do I go about making different particle effects on different terrain textures? It seems like I should just be able to add some code to the manager script for this so it detects what type of terrain texture I'm driving on, but I can't figure it out. Can anyone point me in the right direction? Or is this something that maybe will be added to this package in a future update?
     
  29. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Health is hidden in the inspector, if you go into the script and remove the [System.NonSerialized] before the variable, it will show up. Strength represents how resistant it is to damage, so it doesn't change. GasMotor is a subclass of Motor, which it inherits the health variable from.

    That crash is looking quite good by the way.
    I think you would have to get the mask texture from the terrain data and sample the color of it at the wheel's contact point, then use that to determine what type of terrain the vehicle is on. I'll look into implementing this in the next update, if it's possible.
     
  30. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    I'm wanting to put in a bumper car mini game, I'm thinking this would be perfect for that, I see you have a chase AI but do you have an AI that it could be sort of a free for all?
     
  31. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    With some minor modifications to the FollowAI script it can be set to drive towards the nearest vehicle. You could have a list of all vehicles in the scene, then loop through the list each step to find the nearest one and set it as the target of the script. Make sure to call the InitializeTarget() function on the script when the target is changed.
     
  32. Licarell

    Licarell

    Joined:
    Sep 5, 2012
    Posts:
    434
    Fair enough... I might need your guidance since I'm a neophyte scripting wise, but should be quite fun to play...
     
  33. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    I can offer some help since this sounds simple to implement.
     
  34. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    I thinks you should not implement this, please make the physics asset are clean, only for physics. So everyone can custom or modify code easier. If someone want, his can make by himself, this not belong about physics asset. Please improve the physics features only !
     
  35. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Thanks, you're awesome!! I'll probably dive into this a bit this weekend. If I come up with a solution I'll be sure to post here for everyone :)
     
    Der_Kevin likes this.
  36. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Having vehicles respond dynamically to different terrain types seems like a pretty useful feature, since the relationship between the wheel and ground surface is what vehicle physics are all about. Unity's terrain system is popular, so it makes sense that people would want to use RVP on it. I still have to see if it's practical to sample the masking texture of the terrain every step. Another solution might be generating a low-resolution grid/2D array with information of the mask texture in Start(), then getting the corresponding element of the grid for whichever part of the terrain is being driven on.
     
    HakJak likes this.
  37. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    I known, but i want this kit keep clean code. So everyone can custom or modify if they want. You known, Terrain in Unity only useful for Desktop game, not for Mobile environment and in the assetstore now, have some asset that support check terrain textures. So i recommend, you should improve physics features better than make this features.
     
  38. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
     
  39. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Unless something changed in Unity 5, terrains can be used in both desktop and mobile.

    This is a very good addition to the package and something everyone could find useful.
     
  40. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Good news! I'm about halfway done with this!

    I found some great examples on the forums and modified them to fit into the Wheel.cs script. Now the wheels can get the dominate terrain texture below them by both Index# and Name!

    Now I just need to know the right way to deliver this info to the RVP2 scripts that need them for friction, particles, sounds and tire marks.

    Any advice?

    Since the Index order can change from scene to scene, I figure the best way to go about this is to check the texture name and see if it contains a particular key word. For example, any texture name that contains "mud" should use the mud particles, tire marks, etc.
    I'm just not sure exactly which scripts to change and how I could reference the Master ground reference script.
     
  41. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Guess what, not everyone cares about mobile. Just saying. Skimmed entire thread where you're basically just asking the asset author to make your specific game. That's fair enough but do have consideration for others.
     
    HakJak likes this.
  42. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Basically, the GroundSurfaceMaster script on the GlobalControl object contains a list of surface types with their respective sounds and particles. The GroundSurfaceInstance script is what's attached to the actual surface objects and contains an integer referencing the index for the desired surface type from the main list.

    The Wheel's GetWheelContact() function is what gets the current surface type. The TireMarkCreate script uses this information to generate proper tire marks and particles. The TireScreech script plays the sounds.

    I have some ideas for making this work with terrain, but I'm not decided on anything yet. I'm thinking of adding a new function to the GroundSurfaceInstance script that can be used by the Wheel to fetch the correct surface information based on the wheel's position relative to the textures of the terrain. Each texture could be assigned a surface type index.
     
  43. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Thanks for the speedy reply--as usual! This helps a lot. I think I'm pretty close to getting something functional. Not sure if it's the optimal way to go about it, but it should work. Once I finish I'll email you the modified scripts so you can see what I did and modify/share it however you wish!
     
  44. HakJak

    HakJak

    Joined:
    Dec 2, 2014
    Posts:
    192
    Finally figured it out and it works like a charm! I emailed you 3 modified scripts that add this feature, so feel free to use and share any way you see fit!

    This addition allows you to use keywords rather than index #'s. I highly recommend allowing keywords to be used in your GroundSurfaceInstance scripts as well, so we don't have to try and remember which index #'s correlate with which type of surface. Not essential, of course, but just some polish on this gem of a Unity Asset ;)

    Email title is : Terrain Texture Detection for RVP 2 (HakJak)
     
  45. CoderPro

    CoderPro

    Joined:
    Feb 21, 2014
    Posts:
    327
    Really ? If we make game for desktop, my company will using Unreal Engine instead of Unity 3D. Because, Unity 3D engine so bad to make a PC game. I hate must to using Unity 3D engine for PC game. Unity 3D engine only useful for small mobile game. I request special feature as you did say, but the author will not add that features, so i will add that features by myself. And this is successful implement by me. You should remember, i request only, if the author don't add my request, i will develop by my self to fit with my game. I only want to keep this asset is clean to easy custom or modify. Stop here, ok.
     
  46. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    You seem passionate. Good luck!
     
  47. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    413
    Picked this up a few days ago.

    Any chance you could include a "Drift Kart" sometime?
    Something that acts like the drifts in your Waffle Kart/Mario Kart.
    You know, able to start a drift and steer while maintaining a fairly constant speed around corners.

    Or some tips on how you did that in Waffle Kart. (I know you said before it does not use RVP)
    Just none of the current prefabs have that "Kart" feel where you can start a drift and control it around corners.



    also I noticed some issues with the hover car, it would flip up out of control while taking the test track corners while going over ~100.
    I can do a video if you can't repro it, just take the corners as fast as you can and it will flip (kinda random spots, but I can do it consistently)
    *seems like an issue if someone was making an F-Zero type of game.
     
  48. JustInvoke

    JustInvoke

    Joined:
    Jul 16, 2012
    Posts:
    376
    Thanks, I will check this out and maybe change the way surface types are referenced.
    The kart physics are based around a rigidbody sliding across the ground instead of proper wheel simulations. For drifting, the visual mesh is rotated in local space to give the appearance of drifting while the rigidbody turns a bit to make it actually steer. I might release a kart racer kit sometime, or maybe just the physics. Kart physics like these aren't practical in RVP.

    I think what's happening with the hover car is that it's scraping against mesh colliders and occasionally snapping up because of creases between polygons. I would like to see a video just to make sure this is the same issue. I plan on improving the hovering force in the future so that hover cars don't scrape on the ground so easily.
     
  49. amorrow68

    amorrow68

    Joined:
    Aug 10, 2015
    Posts:
    8
    Noob here. Looking to add a prefab vehicle but it cant seem to get it to work. When I add a prefab car the wheels sit halfway in the plane when dropped onto it. No control. Any tips for setting up? The demo works.Thanks!
     
    Last edited: Aug 24, 2015
  50. amorrow68

    amorrow68

    Joined:
    Aug 10, 2015
    Posts:
    8
    Nevermind. Found the answer in this thread!