Guaranteed repeatable physics?

Just getting back to Unity after around 3 years of not using it. I kind of jumped around from XNA/MonoGame to SpriteKit and back again (with life stuff inbetween of course).

What is the proper way to use the physics engine in Unity in a completely AI driven situation to always get the same result? Take a tower defense game as an example. Let’s assume I want to make sure that towers at locations x, y, and z will always take out 37 of 40 units. This means I can’t have the physics engine acting based on how much time has passed from frame to frame (as rounding could eventually lead to different results from situation to situation, even given the same exact parameters).

My assumption is I need something like below. If I’m correct (or even if not hopefully), could someone point me in the right direction with how I’ll want to change the default setup my project?

func doGameLoop(float timePassed) {
runningTime += timePassed;
while (runningTime >= physicsTimePerFrame) {
runningTime -= physicsTimePerFrame;
processPhysics(timePassed: physicsTimePerFrame);
}

handleGraphicsInputEtc();
}

func processPhysics(timePassed: float) {
//Physics stuff
}

Thanks in advance for any and all help!

Such kind of loop is already provided to you by Unity. Simply create a C# script like this:

using UnityEngine;

public class MyComponent : MonoBehaviour
{
   
    void FixedUpdate ()
    {
        // Handle game logic physics-related stuff
        // Time.deltaTime contains the time that has passed since the last FixedUpdate call
        // Here Time.deltaTime will always contain the fixed timestep.
    }

    void Update ()
    {
        // Handle graphics, input, etc.
        // Time.deltaTime contains the time that has passed since the last Update call
        // Here Time.deltaTime will be variable, based on the framerate
    }  
}