Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Lower-fidelity simulation (offscreen action)

Discussion in 'Scripting' started by gwelkind, Jul 27, 2022.

  1. gwelkind

    gwelkind

    Joined:
    Sep 16, 2015
    Posts:
    66
    Architecture problem that's a bit out of my grasp with Unity. I'm wondering if this is a problem that'd be solved with ECS or jobs, and if anyone could point me to examples/point me in the right direction.

    I have an RTS/adventure game where I'd like to stimulate offscreen action to challenge the player to build autonomous bases that stand up against enemies even when they aren't present.

    The things working to my advantage here are that:
    • The areas where bases can be built are constrained to specific areas, the game will generally have a decent warning when the player may be approaching the base and could do some simulation last minute
    • This isn't the kind of RTS where players need to be able to just flick over to the base, the base can be run at a much lower fidelity and doesn't need to be instantaneously viewable.
    • The base areas are special delegated rooms, can probably be their own scenes, though I'd like to be able to load them additively at full fidelity into the main thread when they're approached.

    So I'd like to simulate these rooms in another thread, at a lower fidelity (i.e. frame rate could probably be down to 1 Hz) the priority is not affecting performance for the real-time game.

    Is there an easy way to run scenes in another thread? This is crazy-- but would launching a headless instance of Unity to run these other scenes in be viable (then just serialize their state when they're ready to be loaded into the main game)?

    Would this be a good use-case for DOTS and, if so, what would be the best way to use DOTS for lower-fidelity areas?

    Is there a way to constrain the resource usage of a job/unity instance in order to avoid it affecting the framerate for the main game?
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,612
    I have a feeling you're way over thinking this.

    In situations like these you want to separate the visuals from the data. If all the enemies, bases, etc, is represented as straight data, that can all be run pretty easily in the background at whatever frequency you want, and the visuals side of things just updates to match what the data is saying.

    This separation of data and visuals is more or less the core of ECS/DOTS as well.
     
    Last edited: Jul 28, 2022
    MelvMay likes this.