Accessing / Altering physics FPS from Lua

Discussion in 'Programming' started by LiterallyAPastry, Jun 15, 2021.

  1. LiterallyAPastry

    LiterallyAPastry
    Expand Collapse

    Joined:
    Jun 15, 2021
    Messages:
    37
    Hello!

    I was wondering if it's possible to access physics FPS from Lua. I'd like to have a lot of cars spawned in on my map, but that naturally has a huge impact on performance.

    Ideally, I'd set physics FPS for distant cars to a lower value and increase it as I get closer, but if that's not something currently exposed to Lua any way to get a bit more performance when having tons of cars would work.

    If car transforms/nodes don't change, does the engine skip calculations? Could I gain more performance by "freezing" vehicle nodes temporarily? Is that something that happens today?

    Thanks!
     
  2. atv_123

    atv_123
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    1,710
    Way back, I think RoR had something similar to this... basically the vehicle would be frozen until you got close enough to interact with it, then it would be loaded and run in the physics engine. I do not think that Beam presently does this, although I know it has been discussed. What all it would require I am unsure. I would think that it should be possible in some way, but I am just unsure how you would go about doing it.
     
  3. EruptionTyphlosion

    EruptionTyphlosion
    Expand Collapse

    Joined:
    Sep 24, 2016
    Messages:
    2,927
    I'm pretty sure this is doable as kissmp does something similar (disabling physics for far away vehicles)
     
  4. Agent_Y

    Agent_Y
    Expand Collapse
    Jbeam/QA support
    BeamNG Team

    Joined:
    Jul 10, 2020
    Messages:
    10,058
    I know that traffic vehicles used to have disabled triangles, thermals and self-collision until they crashed, however I don't think that's a thing anymore, it could have been too buggy or didn't improve performance enough. If they did this instead of freezing the whole car then probably it's not a good idea, but why? No idea.
     
  5. vulcan-dev

    vulcan-dev
    Expand Collapse

    Joined:
    Jan 28, 2017
    Messages:
    245
    Because KissMP is a multiplayer mod it's able to handle all connections meaning that if a user is far away for example, no data will be sent to the client (ie you).
    There's no way to actually do this from Lua itself, all the data is handled by the server therefore it can decide whether to send data or not.
     
  6. Diamondback

    Diamondback
    Expand Collapse
    Vehicle Systems Lead
    BeamNG Team

    Joined:
    Apr 8, 2014
    Messages:
    1,957
    The physics update rate is fixed and can't be changed at runtime. Even it that was possible, it wouldn't be of any use as the vehicles would simply explode as soon as you changed that value.
     
  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