Unsolved Looking for some input - maybe you have a better idea?

Discussion in 'Mod Support' started by krallopian, Mar 18, 2019.

  1. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    790
    Long story short I've developed a drag strip that captures your speed and your time over the line then takes that and displays it via 3D models representing digits 0-9

    upload_2019-3-18_17-13-11.png

    So that picture shows TIME at the top and SPEED at the bottom. You can see the lanes from the left: 1, 2, 4 all have the same time showing even though they weren't exact over the line. The issue here is related to the FPS (as you can see 42 in this screenshot) and thus the timer accuracy.

    If I run in 2x, 4x, 8x, etc.. slow motion, then the timer is far far more accurate so I could setup a trigger near the line that simply sets slow motion. NP. But, to record a video you would end up getting different times for the same run because of processing power.

    I'm running 5.2ghz 12cores, 64gb ram, 1080ti over clocked.. pretty much one of the fastest systems you can throw at the game, so it worries me that the majority of people who would play this would end up with even less accurate times. It's not bad when there are different cars racing, but when you have identical cars traveling 150km/hr over the line, you need a highly accurate timer to display a difference.

    SO, other than triggering slow motion as they cross, can you think of any other way to improve the timer's accuracy taking in to account the fact that it's all related to fps :(

    This is an example of the code I'm using for the timer:

    Code:
    local function onUpdate(dtReal, dtSim, dtRaw)
            timerOne = timerOne+dtSim   
    --- Post updated ---
    Maybe what I can do is take down the time as they cross, and wait a second to display them.

    Currently it says:

    What is the time?
    Truncate the time to 3 decimal points.
    What is that time?
    Take that number and find decimal point 1, convert that to a name representing a 3d object.
    Use that name, and set it to unhidden.

    What is second decimal point?
    Take that number and convert it to a name representing a 3d object.
    Use that name and its visibility.

    Maybe I could say, "take down the time"

    then, "If you took down the time, wait 1 second, then convert and convert and convert etc.."

    Trouble is, I don't think those lines of code really change the accuracy as it's more related to the actual timer accuracy itself such as the frames listed here:
     

    Attached Files:

    • upload_2019-3-18_17-27-29.png
  2. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    I was kinda busy, but I had an itch to find an answer. How would this work?

    Code:
    Engine.Platform.getRealMilliseconds()
    You could do something like:

    Code:
    startTime = Engine.Platform.getRealMilliseconds()
    ...
    finishTime = Engine.Platform.getRealMilliseconds()
    raceTime = finishTime - startTime
    Slow motion problem, though. Hmm.
     
    • Informative Informative x 1
  3. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    790
    Staff Member! Congrats man ;)

    As for the Engine.Platform.getRealMilliseconds() that's a neat trick!

    I've been looking for that for all sorts of reasons, and just kept with starting and stopping a timer using the onUpdate routine (messy imo)

    There must be a way to find out if slomo is activated and IF so, in English would read something like:

    if slowMotionWasActivated find out what speed it was, and multiply the raceTime by that, then when slomo deactivated return to normal counting. Just need to find a line of code for, "if simulation speed changed" and read what it was changed to. Then it'd be easy enough imo.

    The good'ol raceTime = finishTime - startTime is what I was hoping to accomplish using on.osTime or whatever that command is. Thank you @Gamergull
     
  4. Gamergull

    Gamergull
    Expand Collapse
    BeamNG Team

    Joined:
    Jun 3, 2018
    Messages:
    460
    Getting the simulation speed is done like this:

    Code:
    bullettime.get() --Simulation speed value
    bullettime.getReal() --Simulation speed value, with smoothing included
    Once again, I'll be kinda busy for the next while, so if you can figure out the rest, then that's cool. If this solution doesn't work well enough, then I can assist.
     
    • Like Like x 1
    • Informative Informative x 1
  5. krallopian

    krallopian
    Expand Collapse
    NC114-85EKLS
    BeamNG Team

    Joined:
    Dec 5, 2013
    Messages:
    790
    Not going to work on this for now, but again, good to know the commands, thank you!
     
  6. Danny Werewolf

    Danny Werewolf
    Expand Collapse

    Joined:
    Mar 31, 2017
    Messages:
    2,268
    I don't understand a thing, but this sounds awesome.
     
    • Agree Agree x 2
  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