Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Edy's Vehicle Physics - official thread

Discussion in 'Assets and Asset Store' started by Edy, Jan 19, 2012.

  1. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    Looks promising! Some suggestions for you to try:

    - Try setting up the input as described here:
    http://evp.vehiclephysics.com/faq/#how-to-configure-the-input-parameters

    That would give the kart more "agility".

    - Move the "Handling Bias" slider slightly towards "Oversteer". Real karts tend to oversteer in dry surfaces.

    - Adjust the "Steerning Limit" setting so the car's steer angle is smaller with the speed.

    - Reduce the damper in the wheels to increase the response to bumps. At the same time, ensure to adjust suspension length and spring so the suspension doesn't compress to the maximum.

    Keep the good work!
     
    JamesArndt likes this.
  2. BackburnerGames

    BackburnerGames

    Joined:
    Dec 7, 2017
    Posts:
    5
    Thanks Edy!
    I used UnitySteer and a little custom code for the AI. Naturally, I'd like to make them a bit smarter, but I still have a lot to learn about AI. Maybe I overcompensated in other areas to make them more difficult. But basically, if you race only 4 trucks at the lower truck tiers you should do alright. :)
     
  3. martman100

    martman100

    Joined:
    Sep 4, 2013
    Posts:
    18
    Just purchased the asset and after import getting the following error:
    Assets/EVP5/Scripts/Tools/TextureCanvas.cs(554,10): error CS0165: Use of unassigned local variable `pixel'

    Any ideas what I am missing?
    Unity 2017.3.0f3

    UPDATE:
    I fixed this by updating the following function in the TextureCanvas. Color32 pixel; to creating a new empty instance of Color32. When I looked at it the second time I realized there was no way for the compiler to know if anything had been assigned to the struct. I haven't tested it yet but it at least got rid of my compile error.

    Color32 GetAlphaBlendedPixel (Color32 dst)
    {
    Color32 pixel = new Color32();
    pixel.r = (byte)(m_color.r*m_srcAlpha + dst.r*m_dstAlpha);
    pixel.g = (byte)(m_color.g*m_srcAlpha + dst.g*m_dstAlpha);
    pixel.b = (byte)(m_color.b*m_srcAlpha + dst.b*m_dstAlpha);
    pixel.a = (byte)(m_color.a*m_srcAlpha + dst.a*m_dstAlpha);
    return pixel;
    }
     
    Last edited: Jan 4, 2018
  4. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    Sorry for the issue. An update is on the way to the Asset Store.

    The code used to work properly until a recent C# upgrade in Unity.
     
  5. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,960
    When using the VehicleCameraController with smooth follow,
    and then resetting vehicle position (like sending car back to some position),
    the camera jumps a bit and/or looks at wrong direction, probably since the previous car position was that way..

    So basically i want to do full reset, place car on new position and camera on the new position (behind the car).

    i tried resetting m_smoothLastPos value to my reset position, but that didnt help, any ideas?
     
  6. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Hey
    I'm having some trouble with collisions...
    I have setup a simple scene with the bus (also tested with the pickup)... Sometimes! Not every time, the vehicle will intersect with an obstacle (made up of a kinematic rigid body and box collider.. ) and then jump back to position where it should have stopped on collision.
    I have tried replacing the mesh colliders on the vehicles with box colliders to see if mesh collider was causing it.. but no. it still does it. It happens more often in testing on IOS build, but its also occurring in the editor.
    I am not driving fast when it occurs either, so I don't think its physics sub steps... I can literally roll forward and start to drive through the obstacle, about half way through the hud of the pickup.
    Anyone seen this before! Its driving me nuts... ;P

    Unity 2017.3.0f3
    xCode 9.2
    iPad 2017 - IOS 11.0.2


    Cheers
    Richie
     
  7. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Hey, I did some more tests.. not sure if the problem is gone, as it was intermittent, but I replaced the box collider on my obstacles with mesh colliders and things look like they have improved... is so far as I did some tests in a simple test level, and its behaving.

    Anyone experience any physics/collision issues between our vehicles and box colliders?

    Cheers
    Richie
     
  8. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    Hi @richie-greene, sorry, I do not provide support to EVP in Unity .0 versions. I strongly discourage to use any Unity .0 version. Please either upgrade to 2017.3.1 (just released) and/or downgrade to 2017.2.1, then verify if the problem persists.
     
  9. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    @mgear I'm trying to find a way. Looks like that should have been the original behavior, but the effect on switching vehicles in the demo scene looks cool so I didn't get into the issue.
     
  10. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Hey Edy
    Thanks for getting back... Sorry I didn't realise .0 releases were not supported.. I guess they are not patched right?

    Before I choose to upgrade, have you seen any problems with 2017.3.1 along these lines yourself... if you've had time to try it out yet of course.... it did only get released yesterday ;)? My broadband is crap at the moment, so trying to decide to roll back to 17.2.1 or go forward to 17.3.1 for testing first!
    Cheers
    Richie
     
  11. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    They are beta versions released on-schedule in whichever state they are, just for the sake of announcing the new features in Unite / GDC / etc. Stabilization phase begins afterwards.

    I've tested 2017.3.1 and apart from a single crash on exit (happened only once) everything else seems to work correctly.
     
  12. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Thanks Edy.

    I did some more testing... and its happening in 2017.3.1. I'm working on a Mac and building out to IOS.. so I have added my own Input Manager for button input... that just sets the throttleInput and brakeInput directly in your VehicleController script. And I have disabled the Standard Input component.

    So I did a quick test on a Windows PC using just your package and City scene.. all I did was add a basic cube with box collider. I can not reproduce the problem. Including in a windows build. Note: This windows box was running 2017.3.0.

    So what is unique to my Mac version of the app (other than the OS)? Well my input manager... in which I noticed I was setting the throttleInput in Update() and not FixedUpdate()??? Could this mess up physics collisions?

    I will get time later to test my actual input controller on windows box later... But in the meantime, do you see any reason why setting throttleInput in Update() would cause this behaviour?

    Cheers
    Richie
     
  13. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    Correction: it crashes every time when closing Unity. I haven't observed any harmful effect on it.
     
  14. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    @richie-greene setting input parameters in Update or FixedUpdate can't have such effect on the physics.

    Maybe it's worth rolling back to 2017.1.2. 2017.2 introduced a significant bunch of physics and performance issues, and I suspect some of them still remain in present versions.
     
  15. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Hey Edy

    After doing more tests, I reckon you’re right. It has to be a bug, as the test results make no sense! And I found myself trying all sorts of stupid work around that should not be necessary.

    I read that forum thread you linked. Thanks for that... I think going back to v 5.x might be an idea lol
     
    Edy likes this.
  16. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    298
    Hi Edy,

    I have a question about "PowerSliding". I tried many different settings, having good drifts, good doughnut shapes, other drift stuff, but cannot achive continues powersliding on long racing roads. Vehicle easily lose its powersliding after a while or the rear of vehicle pushed to other side suddenly.

    Is there a trick to None-Stop continues powersliding. I see some other games and assets achieve this feature, it seems they override the physics to keep the none-stop powersliding.

    Example ( Is this even possible, none stop controlled power sliding )
     
  17. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    Re-posting this here as it may be an issue related to Edy's Vehicle Physics so mods, take down if I've broken a rule

    Really hoping someone here can help with this problem cos it's frustrating the hell out of me. I just started working with Gaia and I'm getting this crazy collider problem. I'm also using Edy's vehicle physics and I seem to be running into collider geo that just shouldn't be there- you can see it when I'm driving along the road, the car just hops up all the time or even ends up getting stuck see-sawing on geo sometimes. I'm using easy roads 3D for the road network but I've been getting this error since before I even added any roads. Edy's vehicle physics also worked flawlessly for me in the demo scenes provided so I'm not sure where I'm going wrong here. Anybody see this before?

     
  18. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    @serberusno1
    What version of unity are ya using and what platform you building for?
     
  19. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    I'm on unity 2017.3.0f3 and I haven't set any specific build settings for different platforms.
     
  20. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    This might be a long shot, but I was having unexplained physics collision issues with vehicles vs terrain/obstacles in all 2017 versions.... building to ios. But still occurring in editor at times.

    The work around was to disable PCM in physics settings

    Might be worth a try?
     

    Attached Files:

  21. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    I changed it to Legacy on mine and it didn't help at all. It's got to be Gaia related. I think it may be something to do with the LODs, maybe the collider is being generated from the lowest detail LOD or something? Don't know how to check or even remedy this though as I can't figure out how to view the actual collider in the scene
     
  22. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
  23. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    Great tip- this is absolutely the problem. Don't know why the colliders are being generated like this but it's clearly the problem. Any idea how to fix this?

    TerrainCollider_01.jpg
     
  24. GreeneMachine

    GreeneMachine

    Joined:
    Jul 3, 2015
    Posts:
    126
    Im not familiar with Gaia or Easy Roads... is it adding a mesh or terrain collider? Whats the gameobject inspector look like for this terrain.
     
  25. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    As for what I see in that video, I think there are some physics overrides on the car. First, you can see it always rotates gently and smoothly. The maximum angular speed in the Y axis seems to be strictly limited. Something in that direction is the setting Rigidbody.maxAngularVelocity.

    Another possible tweak is the angular rotation in the Y axis being limited with the direction of the movement. So when the rear of the car is suddenly pushed to the other side the angular rotation gets a sudden smooth for not overcoming a certain angle value.
     
  26. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    It looks like a bug in Gaia's collider generator. I'd report this to the authors.

    As a workaround, you may try disabling the generated colliders and adding a MeshCollider to the actual visual meshes.
     
  27. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    Thanks Edy, however one of the Gaia creators actually saw my problem in another thread and he doesn't seem to know what's going on, It's also happening to the standard Unity terrain generator and Unity don't seem to want to help. Also, I can't seem to find an actual mesh to use as collider as it seems to only generate some kind of terrain data file. My last resort as a workaround will be trying to use a third party plugin to export the terrain as a mesh that I can then split up to use as a collider. Pain in the ass though
     
  28. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    I haven't experienced any issue like that on standard Unity terrains. Is there some way one could reproduce the issue starting from an empty scene?
     
  29. MoribitoMT

    MoribitoMT

    Joined:
    Jun 1, 2013
    Posts:
    298
    Hi,

    Rigidbody.maxAngularVelocity worked liked charm, I increased oversteer greatly, disabled traction, lower steering assist, I can do long and great powerslides thank you.

    The only thing left for me is second tweak of limiting the axis-Y on direction of movement. How can achieve this confused me becuase it is not about local angles, it is about direction of movement. I mean vehicle turn around 45 degress, however car keep sliding on forward like 10 degress rotated. How can I find this direction of movement and its angle ?

    EDIT: Finally I find the vehicleController.speedAngle which I needed. Do you have any suggestion how should I limit the vehicle rotation without glitch or effecting physics deeply.
     
    Last edited: Mar 4, 2018
  30. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    You may add a counter-torque when the speed angle is reaching some limit. AddRelativeTorque in ForceMode.Acceleration should do. For example, apply the torque proportionally to the difference between speedAngle and a specified limit. This should create a kind of "damper effect" keeping the angle close to the limit without reaching it.
     
  31. realbrosimple

    realbrosimple

    Joined:
    Jan 12, 2018
    Posts:
    1
    Hey @Edy ! I have my vehicle prefabs in Resources/Prefabs/. When I spawn/ instantiate the vehicle into my scene, it becomes VehicleName(clone) and now VehicleManager/ VehicleTelemetry can't grab the gameobject because target in VehicleController is not referenced. How do I instantiate the vehicle prefab without it being a clone? Any other solutions? Gracias for the help! Love EVP!
     
    Last edited: Mar 17, 2018
  32. facundogalella

    facundogalella

    Joined:
    Mar 5, 2016
    Posts:
    50
    Hi Edy,

    I was wondering if is possible to add a manual gearbox, I tried to do myself but I'm not a programmer, so I find this really hard to do. Can you tell me a point to start?

    Thank you in advance!
     
  33. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    @facundogalella You may modify the properties Max Speed Forwards and Max Drive Force in the vehicle controller based on the emulated gear. The shorter the gear, less speed but more force.

    @realbrosimple answered via PM.
     
    facundogalella likes this.
  34. Dobryakov

    Dobryakov

    Joined:
    Jan 25, 2017
    Posts:
    2
    @Edy, Hello. Is it posiible to stop a vechicle at some position? I mean "go to position and stop" Stopping should be braking, not the rb.velocity = zero.
     
  35. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    @Dobryakov The vehicle controller in EVP exposes the input parameters directly: steerInput, throttleInput, brakeInput. You may easily write a component that use those variables to drive the vehicle to a specific position and stop it there.
     
  36. pathompong

    pathompong

    Joined:
    May 19, 2016
    Posts:
    2
    Is it possible to set the position of the car via transform? My game world is very big and I'm trying to do something similar to Floating Origin script. But whenever it's moving the car to the new origin the car just run out of control and crash. Any help is greatly appreciated.
     
  37. wmaass88

    wmaass88

    Joined:
    Dec 23, 2012
    Posts:
    43
    Hello Edy,

    Is the mirror render texture functionality still available? I can't seem to find how to enable this for individual mirrors. There are a couple mentions of mirrors in this thread but those appear applicable to older versions?
     
  38. pathompong

    pathompong

    Joined:
    May 19, 2016
    Posts:
    2
    I found the solution. I have to save the rigidbody's velocity and angular velocity, set rigidbody to sleep, disable the gameobject, before setting the position, then restore the values back.

    Code (CSharp):
    1.                             var v = rb.velocity;
    2.                             var av = rb.angularVelocity;
    3.                             rb.Sleep();
    4.                             go.SetActive(false);
    5.  
    6.                             go.transform.position += offset;
    7.  
    8.                             go.SetActive(true);
    9.                             rb.velocity = v;
    10.                             rb.angularVelocity = av;
    However, I have another related issue. After teleport the car to the new position, simulated gear shifts back to 0.
     
  39. Kineticon

    Kineticon

    Joined:
    Jun 15, 2017
    Posts:
    2
    Hello Edy,

    Is it possible to use the VehicleTireEffects script on another car controller script that isnt made by you? Im using two different car scripts. The other has different physics and more arcade-like.
     
  40. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    Unlikely. VehicleTireEffects uses data that is calculated in VehicleController. It would require the third party solution to provide the same data in the same format, and the script would need significant work to get adapted.
     
  41. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    Hey can anybody post their input settings for an xbox one controller? I can't seem to get mine set up the way I wanted- I had it before but accidentally deleted it now I can't remember my exact settings. I'm looking to use A+B and left trigger+right trigger as accelerate and brake respectively, and the left stick horizontal in addition to left and right on the D-pad to steer with the vertical stick not doing anything. B as handbrake too but I have that sorted out. I aminly just can't figure out how to use the D-pad for steering and triggers for accelerate and brake
     
  42. obstudio

    obstudio

    Joined:
    Sep 30, 2016
    Posts:
    55
    Vehicle Standard Input -> Throttle and brake Input -> "Separate Axies"
    Project Settings -> Input -> in second occurence of Fire2 -> Positive Button "joystick button7"
    Project Settings -> Input -> in second occurence of Fire3 -> Positive Button "joystick button 6"
    Project Settings -> Input -> in second occurence of Jump -> Positive Button "joystick button 1"
    Project Settings -> Input -> in second occurence of Cancel -> Positive Button leave empty
     
  43. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    Cheers. Started with your settings and figured out my own
     
    obstudio likes this.
  44. toyancsayan

    toyancsayan

    Joined:
    May 4, 2017
    Posts:
    5
    Hello @Edy,

    We are using your Car Psyhic Asset in our games. When we began to use Unity 2018, some smoothing problem occurred, we enabled “use unscaled time” bool in Vehicle Camera Controller to avoid that. Then, we noticed some jitter problem on car when it’s rotating. We downloaded your new Unity Package and build it for Android, jitter problem was there again but not in Editor. We recorded a video to send you. We hope you can help us.


     
  45. Edy

    Edy

    Joined:
    Jun 3, 2010
    Posts:
    1,689
    Hello @toyancsayan, and welcome to the forum!

    Unfortunately, there's some kind of endemic interpolation bug in recent Unity versions. According to Unity, it has been resolved and/or a fix will land in a patch release. I'll try to reproduce the problem and figure out some solution.

    I've just had an idea for you to try:
    1. Disable Interpolation in the vehicle by configuring Interpolate = None in the Rigidbody. This alone reproduces the problem in the Editor.
    2. Find the method LateUpdate in the VehicleCameraController script and rename it to FixedUpdate. This resolves the problem in the Editor.
    Let me know if this trick also resolves the problem in Android.
     
  46. toyancsayan

    toyancsayan

    Joined:
    May 4, 2017
    Posts:
    5
    Hi @Edy,



    Thank you for your reply. First of all, when we want constant 45 fps(Application.framerate=45), this problem occurs. With 60 fps, there is no problem. But in this situation, throttling is seeing after a while. I tried all combination in VehicleCameraController LateUpdate function. I tried Fixed Update, Update and LateUpdate with all delta times and all interpolation property in our project.



    Result is; when jitter is gone, there is no smoothness in game or vice versa. Can vysnc cause this problem?



    Thank you again, we hope this problem will be solved asap.
     
  47. Kineticon

    Kineticon

    Joined:
    Jun 15, 2017
    Posts:
    2
    Hi Edy,

    Is there any way to regulate the Vehicle Nitro? I want to use it but there is no limit to when you can enable the nitro, like as it would decrease over a period of time and regenerate again.

    Thanks! :)
     
  48. oxydozg

    oxydozg

    Joined:
    Jun 16, 2018
    Posts:
    1
    Hi Edy, if you or somebody can gave me advice ,
    I have logitech G29 wheel and with plugin I having steering ,throttle ,brake,controls and they working fine
    I tested LogitechGSDK.LogiPlayConstantForce(index, int value);
    and wheel playing that fine also
    now I need to access force that go in FL and FR wheel ,but because you using for each loop, I can't, or I dont know how to accesss FL(0) FR(1)
    With for loop I can easy access specific index, but foreach loop IDK if it's possible ?
    Or Is there any way to transfer forces from front wheels to the steering wheel in EVP ?

    sorry for my bad english

    Thanks :)
     
  49. dasfuhrer

    dasfuhrer

    Joined:
    Apr 29, 2017
    Posts:
    11
    how to implement mobile inputs ?
     
  50. serberusno1

    serberusno1

    Joined:
    Jan 28, 2017
    Posts:
    83
    I think this has been discussed here before but I can't find it. Is it possible to change how quickly the vehicles wheels turn when you're steering? For instance a big RVs wheels would turn super slowly not snap left to right as I use my controllers thumbsticks
     
unityunity