1. Trouble with the game?
    Try the troubleshooter!

    Dismiss Notice
  2. Issues with the game?
    Check the Known Issues list before reporting!

    Dismiss Notice

Overriding Ai Input

Discussion in 'General Discussion' started by Random Wrecker, May 8, 2020.

Tags:
  1. Random Wrecker

    Random Wrecker
    Expand Collapse

    Joined:
    Apr 12, 2020
    Messages:
    27
    So I am trying to some speed testing, but my problem is that I'm not able to keep the vehicle straight (Yes I use a keyboard and no I am not going to buy a steering wheel.). This is where the Ai comes into play. My Problem with the Ai, however, is that it tries to slow down to stay straight by stopping to use the throttle. Immediately after it reves the engine back up again, which causes the tail to break out. This is fine, because the Ai can straighten itself out (without letting loose of the throttle), but it lets loose of the throttle, which causes the above to happen again. I would only need to do one thing, which is overriding the throttle input of the Ai whilst keeping the steering input of the Ai. I've already looked in the ai.lua file, but didn't see anything, that might cause the user input to be ignored.

    I hope somebody can help me.
    Thanks in advance
     
  2. Sithhy™

    Sithhy™
    Expand Collapse

    Joined:
    Apr 5, 2017
    Messages:
    3,342
    Not sure if my solution will work for your specific case, but what you can do is to spawn 2 cars, pause physics (J), swap to the other car, press Q to change the gearbox mode to Arcade, press the throttle, swap back your vehicle & unpause physics. This will make the other car go full throttle (as you can imagine), but you won't be able to control it from your car & will have to switch to it to correct its trajectory
     
  3. Random Wrecker

    Random Wrecker
    Expand Collapse

    Joined:
    Apr 12, 2020
    Messages:
    27
    But the other car won't be controlled by the Ai, but only drive until it crashes (if I'm right) or I'm just too stupid to understand your reply
     
  4. Nadeox1

    Nadeox1
    Expand Collapse
    Spinning Cube
    BeamNG Team

    Joined:
    Aug 5, 2012
    Messages:
    14,683
    There is no easy way to do what (I understood) you are trying to.
    I would suggest trying mouse-steering instead, it would solve your keyboard limitation (just bind the steering to the mouse X axis, may take a while to get used)
     
  5. Random Wrecker

    Random Wrecker
    Expand Collapse

    Joined:
    Apr 12, 2020
    Messages:
    27
    Sadly I'm not able to steer with the mouse, is there another option? The ai has to deactivate the user input, so there should be a line in ai.lua that does that. Does somebody know where this line is? Maybe the programmer of the Ai?
    Thanks in advance
     
  6. ltntai

    ltntai
    Expand Collapse

    Joined:
    Mar 18, 2017
    Messages:
    656
    Maybe there's a way to hack the cruise control. AI won't use the app (anymore?), but you can still set the speed for fleeing Raven R60. @aljowen
     
  7. aljowen

    aljowen
    Expand Collapse

    Joined:
    Oct 21, 2012
    Messages:
    1,677
    I don't understand what the question is?

    But yes, both the Raven R20 and Raven R60 feature cruise control systems built into the car itself (not an app). However, pressing the brake pedal will deactivate cruise control, and both cars allow the driver to apply throttle while cruise control is enabled for overtaking (after which the car will return to cruise speed).

    So I am not sure that it would solve your issue.


    However, if you opened the Raven R20's "screens.lua" file, you could make the following changes:
    upload_2020-5-9_11-57-19.png
    Some more hacking of the code may be required to get it to work as desired
     
  8. Random Wrecker

    Random Wrecker
    Expand Collapse

    Joined:
    Apr 12, 2020
    Messages:
    27
    I don't want to use the raven, but I want to make the fastest stock car. My experience was that the a blatantly ignored the set Ai speed, but you could manipulate it with the cruise control. But this only works to a certain point and then the Ai overrides it and gets stuck in the "tail breaking out" loop and eventually spins out.
    --- Post updated ---
    I found a way! You can disable the specific steering inputs by commenting out lines in
    Code:
    local function driveCar(steering, throttle, brake, parkingbrake)
    For my purpose I did this:
    Code:
    local function driveCar(steering, throttle, brake, parkingbrake)
      input.event("steering", -steering, 1)
      -- input.event("throttle", throttle, 2)
      -- input.event("brake", brake, 2)
      input.event("parkingbrake", parkingbrake, 2)
    
      lastCommand.steering = steering
      -- lastCommand.throttle = throttle
      -- lastCommand.brake = brake
      lastCommand.parkingbrake = parkingbrake
    end
    
    I didn't think that this would be so easy. I hope this will help somebody in the future.
     
    • Like Like x 1
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice