Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

iRDS - Intelligent Race Driver System Available on Asset Store

Discussion in 'Assets and Asset Store' started by rhodnius, Mar 18, 2013.

?

What you prefer (features are, Transmission, differential and Engine as separate component)

Poll closed Nov 12, 2019.
  1. Release new physics at it's current state and do new stuff on next releases?

    0 vote(s)
    0.0%
  2. Wait for all the new stuff on physics to be implemented then do the release?

    100.0%
  1. FrikkieRSA

    FrikkieRSA

    Joined:
    Mar 30, 2017
    Posts:
    27
    Apologies for not being more specific.

    The position counter changes constantly, however it's never correct. The OnPlayerPositionChange function in IRDSUIPosition constantly gets called, but the position indication is not correct. It says you are for example position 4 out of 6 when you are in fact number 1.

    As for the lap counter, it doesn't seem like the OnLapChange function in IRDSUILap gets called on crossing the finish line. The indication therefore stays at lap 1 irrespective of how many laps you end up driving.
     
    Last edited: Jun 19, 2020
  2. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Thanks for the clarification, and not a problem at all.

    Well i see, can you please try redoing the process track by clicking the process track button and see if that fixes the issue?
     
  3. FrikkieRSA

    FrikkieRSA

    Joined:
    Mar 30, 2017
    Posts:
    27
    I have tried reprocessing the track data a couple of times and it makes no difference. Is there anything in the project settings that the lap and position system is dependent on? For example, certain tags or something?

    Edit: Something in IRDSStatistics is not working correctly. When logging statistics.GetCurrentCarPosition() with statistics referring to IRDSStatistics, the console prints the same incorrect value as shown on the UI. I cannot access IRDSStatistics to see what is going wrong.
     
    Last edited: Jun 20, 2020
  4. vyral13

    vyral13

    Joined:
    Sep 13, 2014
    Posts:
    18
    Yo! Hope all is well!

    Just a quick question regarding the gear system.

    I have created a full tuning system for IRDS in my live game. Which means gears can be added or changed.
    The only problem i face is the gearing for automatic throws up a null ref exception when i remap the gears, so what i am having to do is Car A (5 gear), Car A (6th Gear), Car A (7th Gear) - Not a good setup.
    Ideally just need Car A, then write the gears on start up.

    Eg: I set all the cars to minimum gears that IRDS allows (R / N / 1st). I then create a new array with the correct gears 2/3/4/5 + 6 or 7 if needed. Then rewrite the gear ratios. it works for manual gears, i can manually select the fresh gear setup. But automatic doesnt seem to work.
    Any suggestions?

    Cheers!
     
  5. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Would be taking a test on that Unity version to see if i can get the same behavior.

    Hmm sounds like the array gearSpeed not matching the same length of your gears array, since that is something that is calculated only once, you should use the SetGearRatios method in IRDSDrivetrain class to avoid that issue to happen.
     
  6. vyral13

    vyral13

    Joined:
    Sep 13, 2014
    Posts:
    18
    Thanks so much for the fast reply!

    SetGearRatios method works perfectly! I was simply calling drivetrain.gearRatio[value].

    Now replaced with:
    float[] gears = new float[] {-4.23f, 0, g1,g2,g3,g4,g5};
    drivetrain.SetGearRatios(gears);
    Now I simply have the one car model instead of 3, with minimum number of gears. All set at runtime!

    Thanks again!!!
     
    rhodnius likes this.
  7. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    I have an issue with using nwh physics and the player car is not auto controlled at start of a rolling start any ideas
     
  8. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Also looking at upgrading to nwh 2 physics and not sure if your asset is compatible yet.
     
  9. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    about NWH 2, not yet added an interface script for it, but it shouldnt be that different from the NWH already included.

    About rolling start with NWH, would have to check that one out and see what could be
     
  10. FrikkieRSA

    FrikkieRSA

    Joined:
    Mar 30, 2017
    Posts:
    27
    I have done a test on an empty scene in Unity 2019.4.0f1 and your system works fine. The position indication is correct. So the error is project specific. Please see this post as a reminder: https://forum.unity.com/threads/ird...le-on-asset-store.174548/page-31#post-5998280.

    I have re-imported your latest version without the Project Settings into my project in Unity 2019.4.0f1 and I still have the same errors. As I asked earlier, are there any specific Project Settings that need to be made? I do not want to overwrite my current Project Settings. I have looked at the empty project and aligned my Project Settings with those settings, more specifically the Layer Collision Matrix and Tags and Layers, however the bug still remains. Your manual is not very specific on Project Settings. I only use your AI System and not your vehicles, physics, scenes, etc.

    Also, when I create a new empty scene in my project I get the same error.

    Is the API Updater thing still an issue?

    In your latest version, the following issue is still present: https://forum.unity.com/threads/ird...le-on-asset-store.174548/page-31#post-5754562

    Also, your IRDSUIStandings throws the following exception (see attached). I fixed it by just checking the y float of the Vector2 in UpdateStandingItems() for being NaN.
     

    Attached Files:

    Last edited: Jul 3, 2020
  11. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hmm i see, well some project settings might be needed for the system in order to work properly, check execution order on the project where you imported the project settings from the package to see if there is any script specified there.
     
  12. simdan000

    simdan000

    Joined:
    Jul 10, 2020
    Posts:
    10
    Is it possible to put a money system for unlocking cars and stuff? Please explain easily because I am a beginner. Thanks! :)
     
  13. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    You could add this separately of the System, currently there is a code included for a basic car selection, which you could add a custom script to each car for letting know the car selection if a car is locked/unlocked and then making the select button to be available or not, that would be the easiest way I could think of adding an unlocking car system into it.
     
    simdan000 likes this.
  14. simdan000

    simdan000

    Joined:
    Jul 10, 2020
    Posts:
    10
    Didn't buy this yet, but if I buy it while I am using unity free, can I move it to unity plus or pro without buying it again? ( if it's possible). Please understand because I just downloaded Unity last friday.
    ;-)
     
  15. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    As long as you use the same user to login into unity, it would remain into your purchased Assets ;)
     
  16. simdan000

    simdan000

    Joined:
    Jul 10, 2020
    Posts:
    10
    Thank you so much for answering my questions so quickly! Once again, thank you!
     
    rhodnius likes this.
  17. DarkCooker

    DarkCooker

    Joined:
    Jan 7, 2015
    Posts:
    119
    May I know if this system can support:

    - multiple play over lans / wans ?

    thanks very much
     
  18. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334

    It does support multiplayer with a networking framework like PUN or PUN2 but is not implemented out of the box, but the system does have the needed methods for making it work with multiplayer.

    I can send you some test scripts and steps to get it working with PUN2.

    Cheers
     
  19. ChellaG2w

    ChellaG2w

    Joined:
    Jun 17, 2019
    Posts:
    18
    @rhodnius How can we make the AI control the player car after the race is over ? I want to use it after calling the
    OnRaceEnded event
     
  20. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    The system already does that when the race is over, so i might be missing some other details of what you may want to achieve?
     
  21. ChellaG2w

    ChellaG2w

    Joined:
    Jun 17, 2019
    Posts:
    18
    The car doesnt seem to move over the track points . Is there any special configuration to be done in the IRDSLevelLoadVariables?
     
  22. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    you mean the AI? not sure, would need more information on how you have it setup to be able to give you some guidance.

    So currently the AI is not driving along the track? or is that when the race ends, the player car does not goes into AI mode and drive itself?
     
  23. ChellaG2w

    ChellaG2w

    Joined:
    Jun 17, 2019
    Posts:
    18
    AI is working great . They move on the raceline . I want the the player car to take the raceline once the race is completed

    when the race ends , The player car does not goes into AI mode and drive itself? - This doesn't happen .

    I will debug first and check this issue . I might have missed something .
     
  24. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi @chelladurai_unity , how it went?
     
  25. spawnpointgaming

    spawnpointgaming

    Joined:
    Feb 5, 2019
    Posts:
    16
    Hey @rhodnius ,

    First of all, you did a great job creating iRDS for small developers like us. It simply stands out compared to other car racing physics assets. We are planning to build our first racing game on Android and iOS. And for the same,we are looking to buy iRDS but If you don't mind, I have few queries.
    • What is the difference in your $200 asset pack and $85 asset pack
    • Will Photon multiplayer system compatible with iRDS ?
    • Is Simple IAP system compatible with iRDS ?
    • Are Different race types (Circuit, Sprint, Knockout, Checkpoints, Speed Trap and Capture the flag) available in mobile (Mobile friendly?)
    • Is garage customization included? (Can a user modify his/her car when in garage?)
    Looking forward for a reply.

    Thank you!
     
  26. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Thanks for your interest on iRDS, here are the answers to your questions:

    The difference is that the 200 USD version has all the source code, and 85USD does not (still includes a few scripts, but all the core is in dlls)

    Yes photon is compatible with iRDS, there is no out of the box functionality/scripts, but i can provide some scripts examples for sure.

    If you mean In-app purchases, yes, wont see why it wont be compatible.

    All the different race types are present for all platforms, wont see anything that could make them not run properly on a particular platform

    Garage customization is not out of the box included, but is something you can build on top of the system (like making a system to handle this customization)

    Let me know if you have any further questions.
     
  27. ChellaG2w

    ChellaG2w

    Joined:
    Jun 17, 2019
    Posts:
    18
    Hey sorry for the late reply , i havent checked this yet as i was working on other areas . AI is controlling the player car , but some odd experiences are found
    1) AI is not taking the raceline
    2) AI is reversing the player car and trying to set it to the track , its reversing and then going front and not turning

    I think there might be a configuration issue in the IRDSLevelLoadVariables from my end .

    BTW ,
    are there any known issues of iRDS in 2019.4 ?I am planning to migrate the project to 2019.4 Apart from saving and restoring the setup , are there any specific things to be considered? If so please share a link here for best practices apart from this
    https://www.tapatalk.com/groups/daga_games_forum/version-releases-and-news-t24-s30.html#p253
     
  28. DevTheIndieDev

    DevTheIndieDev

    Joined:
    Aug 21, 2020
    Posts:
    1
    Hi,
    @rhodnius
    Good template.

    Please can you answer my questions. I was not finding on description.

    - Do you have any tutorials as how to save & load a modified car (for say color or texture or hood etc by user on mobile) after game restarts ?

    - Is there any tutorial how to save modified car or game progress using your asset in cloud (using google play or facebook etc) ?

    - Do you have any sample shop setup where user can purchase car or unlock car using in-game currency or any tutorial as how to setup using your asset ?

    - Is there any tutorial to showcase how the recent asset works on youtube ?

    - Can use use easy save or save game kit asset with IRDS to save players progress & modified car etc or the progress or modified car is saved locally ?

    thanks in advance
     
  29. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    If you are already on the latest version of iRDS from the asset store, you should be fine, always do a full project backup just in case (not needed if you are on a git repo)

    Thanks!, sure here are the answers:

    Those features are not part of iRDS, those should be made separately. You could use player prefs for saving those details.

    Those features are not part of iRDS, those should be made separately, and thats the reason for not having a tutorial for it.

    Those features are not part of iRDS, those should be made separately.

    The main features have not changed in their core, so the tutorial still applies to the latest version. :)

    Yes you can, you could also implement your Data class that could hold the information you want to save/load and a data loader/reader to set it to the cars/player progress/unlocked cars/upgrades/etc.
     
  30. ChellaG2w

    ChellaG2w

    Joined:
    Jun 17, 2019
    Posts:
    18
    @rhodnius i am facing an issue when i am trying to set the racing line for a new track .
    Its a simple oval track and at the corners i can see the line being red so that the car slows down . But i noticed the following
    1) Car slows down , but slides and hits the wall
    2) Car brakes and can notice that the tire rotates and the raycast is trying to keep the car on the racing line .

    How can the car apply more break so that it tries to keep on the racing line ?
     
  31. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hi @chelladurai_unity

    Check your settings for the AI on the levelload object, specifically for cornering speed factor, and lower this value until the cars can drive properly through corners.
     
  32. ChellaG2w

    ChellaG2w

    Joined:
    Jun 17, 2019
    Posts:
    18
    Thanks , this worked like a charm
     
    rhodnius likes this.
  33. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    104
    Hi. Is IRDS compatible with NWH2 for the AI?

    Cheers
     
    fredastaire likes this.
  34. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    I tried to adapt the nwh script but no luck as gears are way different
     
  35. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Also when I use nwh script the player never gains control
     
  36. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    104
    Thanks for getting back to me. If I make any headway I'll let you know.

    Cheers
     
  37. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Is not out of the box, but it is with NWH1, so adding NWH2 interface script shouldn't be a problem
     
  38. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    How are gears on NWH2? if you explain them to me i would help out on creating the interface script for sure. Same for getting the player get control of the player car.

    Let me know, so I can help you guys on it
     
  39. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using NWH.VehiclePhysics2;
    4. using IRDS.AI;
    5. using IRDS.Game;
    6.  
    7. public class IRDSCarControllInputNWH : MonoBehaviour
    8. {
    9.  
    10.     // cached reference for CarControl
    11.     public VehicleController drivetrain;
    12.     public IRDSCarControllInput carInputs;
    13.     public IRDSCarControllerAI carAI;
    14.     private float airDrag;
    15.     public Transform[] frontWheels;
    16.  
    17.     public float[] kfriction = { 1, 1 };
    18.     // Initialize
    19.     void Awake()
    20.     {
    21.         if (drivetrain == null)
    22.             drivetrain = GetComponent<VehicleController>();
    23.         if (carInputs == null)
    24.             carInputs = GetComponent<IRDSCarControllInput>();
    25.         if (carAI == null)
    26.             carAI = GetComponent<IRDSCarControllerAI>();
    27.         //        airDrag = drivetrain.maxSpeed;
    28.         carAI.SetFrictionExtaernalPhysics(kfriction);
    29.         carInputs.SetTopSpeedExternalPhysics(150f);
    30.         carAI.SetHFactorExternalPhysics(0.2f);
    31.         carAI.SetClFactorExternalPhysics(0.3f);
    32.         carAI.SetWingaFactorExternalPhysics(1f);
    33.     }
    34.     void Start()
    35.     {
    36.         drivetrain.Active = true;
    37.  
    38.         carAI.SetIRDSWheelsCenter(frontWheels);
    39.         carAI.SetMaxSteerLockExternalPhysics(28);
    40.         carInputs.gearRatiosLengthExternalPhysics = 3;
    41.         carInputs.maxRpmExternalPhysics = 1000;
    42.         carInputs.gearSpeedsExternalCarPhysics = new float[3];
    43.  
    44.     }
    45.  
    46.  
    47.     void FixedUpdate()
    48.     {
    49.         if (!carInputs.GetCarPilot())
    50.         {
    51.             carController();
    52.         }
    53.         else
    54.         {
    55.             if (carAI.NavigateTWaypoints.GoPits)
    56.                 if (carInputs.GetCarSpeed() > IRDSWPManager.GetPitMaxSpeed())
    57.                 {
    58.                     //No way to limit the car speed on RCC
    59.                 }
    60.             if (carInputs.auto1 || carInputs.auto2 || carInputs.auto3)
    61.                 PlayerController();
    62.             if (IRDSStatistics.GetCanRace())
    63.             {
    64.                 drivetrain.Active = true;
    65.             }
    66.             else
    67.             {
    68.                 drivetrain.Active = false;
    69.             }
    70.         }
    71.     }
    72.  
    73.     void carController()
    74.     {
    75.  
    76.         drivetrain.input.Steering = carInputs.GetSteerInput();
    77.         drivetrain.input.Handbrake = carInputs.GetHandBrakeInput();
    78.  
    79.         if (IRDSStatistics.GetCanRace() || carAI.rollingStart)
    80.         {
    81.             if (carInputs.targetGearExtarnelPhysics - 1 < 1)
    82.             {
    83.                 drivetrain.input.Throttle = -carInputs.GetThrottleInput();
    84.             }
    85.             else
    86.             {
    87.                 drivetrain.input.Throttle = carInputs.GetThrottleInput();
    88.  
    89.             }
    90.             drivetrain.input.Handbrake = carInputs.GetBrakeInput();
    91.         }
    92.         else
    93.         {
    94.             drivetrain.input.Throttle = 0;
    95.             drivetrain.input.Handbrake = 1;
    96.         }
    97.  
    98.     }
    99.  
    100.     void PlayerController()
    101.     {
    102.  
    103.         if (carInputs.auto3)
    104.             drivetrain.input.Vertical = carInputs.GetThrottleInput();
    105.         else
    106.         {
    107.  
    108.             if (Input.GetKey(KeyCode.UpArrow))
    109.                 drivetrain.input.Vertical += 0.05f;
    110.             drivetrain.input.Vertical = Mathf.Clamp01(drivetrain.input.Vertical);
    111.         }
    112.         if (carInputs.auto1)
    113.             drivetrain.input.Vertical = -carInputs.GetBrakeInput();
    114.         else
    115.         {
    116.  
    117.             if (Input.GetKey(KeyCode.DownArrow))
    118.                 drivetrain.input.Vertical -= 0.05f;
    119.         }
    120.  
    121.         if (carInputs.auto2)
    122.             drivetrain.input.Steering = carInputs.GetSteerInput();
    123.         else
    124.         {
    125.  
    126.             drivetrain.input.Steering = Mathf.Clamp(Input.GetAxis("Steering"), -1, 1);
    127.             //            drivetrain.steerInput=Mathf.Clamp(drivetrain.steerInput,-1,1);
    128.         }
    129.  
    130.         drivetrain.input.Handbrake = carInputs.GetHandBrakeInput();
    131.  
    132.         //        drivetrain.gearInput = carInputs.GetGearInput();
    133.     }
    134.  
    135.  
    136.     //end line
    137. }
    the issue i have left is drivetrain.active
     
    rhodnius likes this.
  40. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Nw2 has brake and throttle separated if that matters
     
  41. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using NWH.VehiclePhysics2;
    4. using IRDS.AI;
    5. using IRDS.Game;
    6.  
    7. public class IRDSCarControllInputNWH : MonoBehaviour
    8. {
    9.  
    10.     // cached reference for CarControl
    11.     public VehicleController drivetrain;
    12.     public IRDSCarControllInput carInputs;
    13.     public IRDSCarControllerAI carAI;
    14.     private float airDrag;
    15.     public Transform[] frontWheels;
    16.  
    17.     public float[] kfriction = { 1, 1 };
    18.     // Initialize
    19.     void Awake()
    20.     {
    21.         if (drivetrain == null)
    22.             drivetrain = GetComponent<VehicleController>();
    23.         if (carInputs == null)
    24.             carInputs = GetComponent<IRDSCarControllInput>();
    25.         if (carAI == null)
    26.             carAI = GetComponent<IRDSCarControllerAI>();
    27.         //        airDrag = drivetrain.maxSpeed;
    28.         carAI.SetFrictionExtaernalPhysics(kfriction);
    29.         carInputs.SetTopSpeedExternalPhysics(150f);
    30.         carAI.SetHFactorExternalPhysics(0.2f);
    31.         carAI.SetClFactorExternalPhysics(0.3f);
    32.         carAI.SetWingaFactorExternalPhysics(1f);
    33.     }
    34.     void Start()
    35.     {
    36.         drivetrain.enabled = true;
    37.  
    38.         carAI.SetIRDSWheelsCenter(frontWheels);
    39.         carAI.SetMaxSteerLockExternalPhysics(28);
    40.         carInputs.gearRatiosLengthExternalPhysics = 3;
    41.         carInputs.maxRpmExternalPhysics = 1000;
    42.         carInputs.gearSpeedsExternalCarPhysics = new float[3];
    43.  
    44.     }
    45.  
    46.  
    47.     void FixedUpdate()
    48.     {
    49.         if (!carInputs.GetCarPilot())
    50.         {
    51.             carController();
    52.         }
    53.         else
    54.         {
    55.             if (carAI.NavigateTWaypoints.GoPits)
    56.                 if (carInputs.GetCarSpeed() > IRDSWPManager.GetPitMaxSpeed())
    57.                 {
    58.                     //No way to limit the car speed on RCC
    59.                 }
    60.             if (carInputs.auto1 || carInputs.auto2 || carInputs.auto3)
    61.                 PlayerController();
    62.             if (IRDSStatistics.GetCanRace())
    63.             {
    64.                 drivetrain.enabled = true;
    65.             }
    66.             else
    67.             {
    68.                 drivetrain.enabled = false;
    69.             }
    70.         }
    71.     }
    72.  
    73.     void carController()
    74.     {
    75.  
    76.         drivetrain.input.Steering = carInputs.GetSteerInput();
    77.         drivetrain.input.Handbrake = carInputs.GetHandBrakeInput();
    78.  
    79.         if (IRDSStatistics.GetCanRace() || carAI.rollingStart)
    80.         {
    81.             if (carInputs.targetGearExtarnelPhysics - 1 < 1)
    82.             {
    83.                 drivetrain.input.Throttle = -carInputs.GetThrottleInput();
    84.             }
    85.             else
    86.             {
    87.                 drivetrain.input.Throttle = carInputs.GetThrottleInput();
    88.  
    89.             }
    90.             drivetrain.input.Handbrake = carInputs.GetBrakeInput();
    91.         }
    92.         else
    93.         {
    94.             drivetrain.input.Throttle = 0;
    95.             drivetrain.input.Handbrake = 1;
    96.         }
    97.  
    98.     }
    99.  
    100.     void PlayerController()
    101.     {
    102.  
    103.         if (carInputs.auto3)
    104.             drivetrain.input.Throttle = carInputs.GetThrottleInput();
    105.         else
    106.         {
    107.  
    108.             if (Input.GetKey(KeyCode.UpArrow))
    109.                 drivetrain.input.Throttle += 0.05f;
    110.             drivetrain.input.Throttle = Mathf.Clamp01(drivetrain.input.Throttle);
    111.         }
    112.         if (carInputs.auto1)
    113.             drivetrain.input.Brakes = carInputs.GetBrakeInput();
    114.         else
    115.         {
    116.  
    117.             if (Input.GetKey(KeyCode.DownArrow))
    118.                 drivetrain.input.Throttle -= 0.05f;
    119.         }
    120.  
    121.         if (carInputs.auto2)
    122.             drivetrain.input.Steering = carInputs.GetSteerInput();
    123.         else
    124.         {
    125.  
    126.             drivetrain.input.Steering = Mathf.Clamp(Input.GetAxis("Steering"), -1, 1);
    127.             //            drivetrain.steerInput=Mathf.Clamp(drivetrain.steerInput,-1,1);
    128.         }
    129.  
    130.         drivetrain.input.Handbrake = carInputs.GetHandBrakeInput();
    131.  
    132.         //        drivetrain.gearInput = carInputs.GetGearInput();
    133.     }
    134.  
    135.  
    136.     //end line
    137. }
    138.  
    this lets me use my car but the ai cars just immediatly crash to the left
     
    Last edited: Sep 12, 2020
  42. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    I’m using rolling start the player car doesn’t move right away but ai cars just crash to the left at the start. Is this an issue with changing drivetrain.active to drivetrain.enabled to rid errors?
     
  43. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334

    Would have to check that out, but definitely is related to what you are stating. can you try without rolling start and see if it behave correctly?
     
  44. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    I tried standing start they don’t move at all but the steering and throttle are being accessed 419FDEA0-FBC9-4285-87D0-F712556D0665.jpeg
     
  45. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    I see, then I strongly suggest we do a remote session to help you out faster, since if it's not working with standing start, then something else is the issue, PM if you would like to do the remote session.

    Cheers
     
  46. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
  47. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    yeah that would help, so what can be done is replacing the enable disable with making the handbrake to be 1 (for replacing the disable) and 0 for the enable something like this: (also I cleaned the code a bit)

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using NWH.VehiclePhysics2;
    4. using IRDS.AI;
    5. using IRDS.Game;
    6. public class IRDSCarControllInputNWH : MonoBehaviour
    7. {
    8.     public VehicleController drivetrain;
    9.     public IRDSCarControllInput carInputs;
    10.     public IRDSCarControllerAI carAI;
    11.     private float airDrag;
    12.     public Transform[] frontWheels;
    13.     public float[] kfriction = { 1, 1 };
    14.     // Initialize
    15.     void Awake()
    16.     {
    17.         if (drivetrain == null)
    18.         {
    19.             drivetrain = GetComponent<VehicleController>();
    20.         }
    21.  
    22.         if (carInputs == null)
    23.         {
    24.             carInputs = GetComponent<IRDSCarControllInput>();
    25.         }
    26.  
    27.         if (carAI == null)
    28.         {
    29.             carAI = GetComponent<IRDSCarControllerAI>();
    30.         }
    31.      
    32.         carAI.SetFrictionExtaernalPhysics(kfriction);
    33.         carInputs.SetTopSpeedExternalPhysics(150f);
    34.         carAI.SetHFactorExternalPhysics(0.2f);
    35.         carAI.SetClFactorExternalPhysics(0.3f);
    36.         carAI.SetWingaFactorExternalPhysics(1f);
    37.     }
    38.     void Start()
    39.     {
    40.         drivetrain.enabled = true;
    41.         carAI.SetIRDSWheelsCenter(frontWheels);
    42.         carAI.SetMaxSteerLockExternalPhysics(28);
    43.         carInputs.gearRatiosLengthExternalPhysics = 3;
    44.         carInputs.maxRpmExternalPhysics = 1000;
    45.         carInputs.gearSpeedsExternalCarPhysics = new float[3];
    46.     }
    47.     void FixedUpdate()
    48.     {
    49.         if (!carInputs.GetCarPilot())//Is not Player controlled
    50.         {
    51.             carController();
    52.         }
    53.         else
    54.         {
    55.             PlayerController();
    56.         }
    57.     }
    58.     void carController()
    59.     {
    60.         drivetrain.input.Steering = carInputs.GetSteerInput();
    61.         drivetrain.input.Handbrake = carInputs.GetHandBrakeInput();
    62.         if (IRDSStatistics.GetCanRace() || carAI.rollingStart)
    63.         {
    64.             if (carInputs.targetGearExtarnelPhysics - 1 < 1)
    65.             {
    66.                 drivetrain.input.Throttle = -carInputs.GetThrottleInput();
    67.             }
    68.             else
    69.             {
    70.                 drivetrain.input.Throttle = carInputs.GetThrottleInput();
    71.             }
    72.             drivetrain.input.Handbrake = carInputs.GetBrakeInput();
    73.         }
    74.         else
    75.         {
    76.             drivetrain.input.Throttle = 0;
    77.             drivetrain.input.Handbrake = 1;
    78.         }
    79.     }
    80.     void PlayerController()
    81.     {
    82.         UpdateThrottlePlayerInput();
    83.         UpdateBrakePlayerInput();
    84.         UpdateSteeringPlayerInput();
    85.         UpdateHandbrakePlayerInput();
    86.     }
    87.  
    88.     private void UpdateThrottlePlayerInput()
    89.     {
    90.         if (carInputs.auto3)
    91.         {
    92.             drivetrain.input.Throttle = carInputs.GetThrottleInput();
    93.         }
    94.         else
    95.         {
    96.             if (Input.GetKey(KeyCode.UpArrow))
    97.             {
    98.                 drivetrain.input.Throttle += 0.05f;
    99.             }
    100.             else
    101.             {
    102.                 drivetrain.input.Throttle -= 0.05f;
    103.             }
    104.  
    105.             drivetrain.input.Throttle = Mathf.Clamp01(drivetrain.input.Throttle);
    106.         }
    107.     }
    108.  
    109.     private void UpdateBrakePlayerInput()
    110.     {
    111.         if (carInputs.auto1)
    112.         {
    113.             drivetrain.input.Brakes = carInputs.GetBrakeInput();
    114.         }
    115.         else
    116.         {
    117.             if (Input.GetKey(KeyCode.DownArrow))
    118.             {
    119.                 drivetrain.input.Brakes += 0.05f;
    120.             }
    121.             else
    122.             {
    123.                 drivetrain.input.Brakes -= 0.05f;
    124.             }
    125.  
    126.             drivetrain.input.Brakes = Mathf.Clamp01(drivetrain.input.Brakes);
    127.         }
    128.     }
    129.  
    130.     private void UpdateSteeringPlayerInput()
    131.     {
    132.         if (carInputs.auto2)
    133.         {
    134.             drivetrain.input.Steering = carInputs.GetSteerInput();
    135.         }
    136.         else
    137.         {
    138.             drivetrain.input.Steering = Mathf.Clamp(Input.GetAxis("Steering"), -1, 1);
    139.         }
    140.     }
    141.  
    142.     private void UpdateHandbrakePlayerInput()
    143.     {
    144.         //This should be changed for an actual input of the player?
    145.         drivetrain.input.Handbrake = carInputs.GetHandBrakeInput();
    146.  
    147.         if (IRDSStatistics.GetCanRace() == false)          
    148.         {
    149.             drivetrain.input.Handbrake = 1;
    150.         }
    151.     }
    152.     //end line
    153. }
    Also you should be having the cars with automatic gear shifting, as i don't see any gear shifting code on this script

    Let me know how it goes
     
  48. mthawley

    mthawley

    Joined:
    Sep 7, 2018
    Posts:
    104
    Hi. I noticed that when using the NWH2 script above the generated Center container transform for both AI and Player cars is wrong.

    upload_2020-9-21_11-15-25.png

    Once I manually set the position to 0 I can control the player car, however the AI never moves. Note that this also affects the car size in IRDS Car Controller AI.

    upload_2020-9-21_11-14-56.png

    I have checked this with a number of NWH2 cars and this always happens, however this doesn't happen when using the RCC script for RCC cars.

    @fredastaire - could you please check if this is happening to you too?

    @rhodnius - a couple of points regarding the script above. Should line 72 be updating drivetrain.input.Brakes (not HandBrake)?
    Also, does the PlayerController need to be updating the NWH2 input controls? Doesn't NWH2 already handle this? If so, then NWH2 now uses the new Input System so the input scripts need to reflect this.

    Cheers.
     
  49. fredastaire

    fredastaire

    Joined:
    Sep 10, 2017
    Posts:
    90
    I tried new script and no luck either I haven’t played with any code yet.
     
  50. rhodnius

    rhodnius

    Joined:
    Apr 11, 2012
    Posts:
    1,334
    Hmm this happened also with NWH version 1, and the issue was the inner gameobjects of the car that have non 1 scale on their transforms if I'm not wrong and my mind is not failing me, but pretty sure is the same issue.

    and yes line 72 is wrong should be updating brake and not hand brake as you stated

    About NWH2 input controls, you could make just an override to it when the race has not started in case of standing starts, so the player can not move forward, and let the NWH2 handle inputs when the race starts

    Edit: sounds to me also that there might be a clash between NWH inputs and the interface script inputs maybe? can you guys please check if the cars have an Inputs script/module in it?
     
    Last edited: Sep 25, 2020