Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created May 4, 2018 10:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tsubaki/e8a56037cca081fac8624457074d9a5b to your computer and use it in GitHub Desktop.
Save tsubaki/e8a56037cca081fac8624457074d9a5b to your computer and use it in GitHub Desktop.
using UnityEngine;
public class PSim : MonoBehaviour {
[SerializeField][Range(1, 5)] float maxTime = 0.1f;
private void Awake()
{
Physics.autoSimulation = false;
}
private void Start()
{
float time = 0;
while(time < maxTime)
{
Physics.Simulate(Time.fixedDeltaTime);
time += Time.fixedDeltaTime;
}
}
private void OnDestroy()
{
Physics.autoSimulation = true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment