Modify steering axis input value to automatically countersteer?

Discussion in 'Programming' started by [CAMSO] Lurlidon, Aug 20, 2019.

  1. [CAMSO] Lurlidon

    [CAMSO] Lurlidon
    Expand Collapse

    Joined:
    Oct 11, 2017
    Messages:
    6
    Hey team,

    I'd like to try implement an app to automatically counter-steer to make drifting on a keyboard or controller a little easier.

    My previous implementations of this have basically boiled down to:

    Code:
    Handle the player's steering axis input parameter
    If the player's steering input axis almost equals 0 (i.e no input)
        Find the angle between the vehicle's forward direction and direction of velocity around the car's up direction
        Set the steering input axis value to the target angle's inverse lerp value between the theoretical min/max steering angle. (try set the input to point the wheels in the direction of velocity, basically)
    Handle steering angle as per usual
    Would this be possible with a basic BeamNG App? Do we have enough control to get & set the axis input before beamNG reads it & applies it to the car?

    I looked into the Remote Control app and the Cruise Control app but sadly neither really gave me a base to work off. Do any other apps directly modify input?
     
    • Like Like x 2
    • Agree Agree x 1
  2. ikt

    ikt
    Expand Collapse

    Joined:
    Aug 18, 2016
    Messages:
    18
    Hi, I'd also be interested in this. Mostly to re-implement my own GTA implementation - is there any documentation or any base script example available to start from?

    I've never used Lua, but as long as there's some API thing to direct set control (judging by that remote control app, there is) and read the current (relative) velocity, it should be fine.

    For reference - GTA Vs re-implementation:

    PHP:
    // Returns in radians
    float Racer_calculateDesiredHeading(float steeringMaxfloat desiredHeading,
        
    float reduction) {
        
    desiredHeading *= reduction// TODO: Figure out if this is what R* does or not
        
    float correction desiredHeading;

        
    Vector3 speedVector ENTITY::GET_ENTITY_SPEED_VECTOR(vehicletrue);
        if (
    abs(speedVector.y) > 3.0f) {
            
    Vector3 target Normalize(speedVector);
            
    float travelDir atan2(target.ytarget.x) - static_cast<float>(M_PI) / 2.0f;
            if (
    travelDir static_cast<float>(M_PI) / 2.0f) {
                
    travelDir -= static_cast<float>(M_PI);
            }
            if (
    travelDir < -static_cast<float>(M_PI) / 2.0f) {
                
    travelDir += static_cast<float>(M_PI);
            }
            
    // Correct for reverse
            
    travelDir *= sgn(speedVector.y);
            
    // Custom user multiplier
            
    travelDir *= settings.CustomSteering.CountersteerMult;

            
    // Steering-corrected value
            
    travelDir std::clamp(travelDirdeg2rad(-settings.CustomSteering.CountersteerLimit), deg2rad(settings.CustomSteering.CountersteerLimit));

            
    correction travelDir desiredHeading;
        }

        return 
    std::clamp(correction, -steeringMaxsteeringMax);
    }
    (Forgive my abuse of the PHP tag, as there's no Cpp tag I could find)

    Also for reference / proof that this would be effective - disabling GTA Vs countersteering filtering and directly applying a (lerped) user input, immediately results in the sluggish hard-to-correct driving, much like BeamNG.
     
    • Informative Informative x 1
  3. G-Farce

    G-Farce
    Expand Collapse

    Joined:
    Apr 1, 2016
    Messages:
    585
    Why hasn't this gained more traction? It's Genius.
     
    • Like Like x 1
  4. ikt

    ikt
    Expand Collapse

    Joined:
    Aug 18, 2016
    Messages:
    18
    Ideally I'd like to see this added as a default option, but the BeamNG team seems to have shot the idea down.

    For what reason, I don't know. Having the thumb stick force not matching physical force just seems like a very naive implementation.
     
    • Agree Agree x 1
  5. G-Farce

    G-Farce
    Expand Collapse

    Joined:
    Apr 1, 2016
    Messages:
    585
    Yeah. I mean it's playable without it, if you concentrate and drive like a nanny, but oh my gawd it'd be amazing with this.
     
  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