Control Based Input Recording/Playback for Script AI

Discussion in 'Ideas and Suggestions' started by MWorld262, Apr 12, 2021.

  1. MWorld262

    MWorld262
    Expand Collapse

    Joined:
    Sep 9, 2019
    Messages:
    11
    I like many other players occasionally like to make cool Beamng car stunt and chase videos. The script AI manager is a great tool to set up car chases or a t-bone crash at an intersection. Something that I feel could make this tool even better is an option to record controller inputs on a specific vehicle and play them back (sort of like controller inputs in a TAS). With a function like that, it would be so much easier to do stuff like tandem drifting and stunts that require advanced vehicle movements.

    It would work a bit like Script AI, where you can create a path for an AI to drive along, but instead of just recording an AI path, it would record your controller inputs. That way, when recording you could execute a stunt like a drift, timed jump at a specific speed, reverse 180, or handbrake turn and be able to play it back in real-time like an AI script. You would then be able to drive another vehicle while playing back the functions of the first vehicle and create epic police chases and timed stunts or crashes. You could also have the script stop playing if you knock the vehicle off course (to avoid a frustrating mess up) or have the AI somehow bring it back on course (if possible).

    I feel that a tool like this would open up so many possibilities for people to create even more awesome videos and scenarios. I can only imagine what a very talented player could do with a tool like this.

    Edit: The tool would record your controller inputs like throttle, braking, steering, etc. in correlation to the map and when you made the input. Kind of like a script AI path.
    Think of a TAS, in this video, you can see the button inputs (bottom left) are merely played back in the game.

    A tool like this in AI Script manager where you could tie it to a specific vehicle would really cool and useful for stunts/scenarios.


    Thanks for reading :)
     
    #1 MWorld262, Apr 12, 2021
    Last edited: Apr 12, 2021
    • Like Like x 1
    • Agree Agree x 1
  2. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    I think it would be cool to perform handbrake turns or reverse 180s with a touch of a button anywhere on the map since Script AI can only play the recording in the recorded location! One problem I see is when playing back the controller recording, the vehicle needs to be at the exact speed the stunt was performed because you doing a reverse 180 at 60 mph requires a different set of inputs compared to one done at 30 mph. So the solution would be to get the vehicle up to the speed the stunt was performed at. But another problem is differing surfaces (bumpy, different grip levels, etc.) between the place you recorded at and the location you are playing the recording back, which the recording can't account for. But as long as you play it back on similar surfaces, it should be fine.
     
  3. MWorld262

    MWorld262
    Expand Collapse

    Joined:
    Sep 9, 2019
    Messages:
    11
    Oh ya, I can see that. I think I was a bit unclear. It would work like script AI, where the car always starts at A and drives along the recorded path that you drove to B (controller inputs such as throttle, steering braking, etc would be tied to a location on the map or AI path). So the car would always recreate your recorded drive. The playback would already have your vehicle traveling at a specific speed because of your recorded throttle inputs. You can actually do what you're talking about right now if you have a program on your pc to record function keys.
     
    #3 MWorld262, Apr 12, 2021
    Last edited: Apr 12, 2021
  4. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Okay, I was about to write what this would offer over Script AI, but I went ahead and tried some stunts using Script AI and now I see your point. Yeah I think the devs really should include controller input-based recording.
     
    • Agree Agree x 1
  5. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    Unfortunately, this is very difficult to do with just input recordings. The game is not running in deterministic mode, which means that two executions of the same thing won't necessarily lead to exactly the same result. This in term means that the slight differences between two executions sum up over time, leading to a larger and larger overal deviation from the desired result.

    One would have to have so called key-frames where absolute data is stored in order to correct for accumulated errors and then somehow combine that with the (relative) input commands.
     
    • Like Like x 1
  6. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    It seems to me that some parts of the game are actually running in deterministic mode, since the delta time parameter of some calling functions is held constant and therefore the rate at which the calling/called functions are called is also fixed. For example, in the file "BeamNG.drive\lua\vehicle\main.lua" of the function @ line 63:
    Code:
    function onPhysicsStep(dtSim)
    its parameter "dtSim" is held at a constant value (called from the C++ game engine?).

    And so I'm curious why some module's "update" functions are called at a fixed rate but others aren't and at a variable rate (like input.updateGFX(dtSim)).
     
  7. Fahrenwx

    Fahrenwx
    Expand Collapse

    Joined:
    Dec 23, 2020
    Messages:
    5
    I think we should be able to play in replays. Be able to spawn cars and all the stuff, might answer to ScriptAI's current problem.
     
    • Like Like x 1
  8. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,683
    Update is called from the physics, which is a fixed 2000fps
    UpdateGFX is called on each graphics frame, so frame times (and therefore dt) vary
     
  9. MWorld262

    MWorld262
    Expand Collapse

    Joined:
    Sep 9, 2019
    Messages:
    11
    That's what Im saying!
     
  10. angelo234

    angelo234
    Expand Collapse
    Programmer
    BeamNG Team

    Joined:
    Aug 11, 2017
    Messages:
    540
    Yes I know that about those two update functions, but I'm curious why the devs decided on updating some of the modules at a constant rate and others at a variable rate. Because if they want to achieve closer to deterministic results, they would just need to update all the modules (like user input) using the update function that runs at a constant rate instead of updateGFX which runs at a variable rate.
     
  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