-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Don't inherit from Academy, remove virtual methods #3184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
c241b97
fb9cef9
abee213
5e21640
ad556a8
d6b3718
45cee86
44c37a5
f6889d7
25627b4
de8be79
d6b8b1e
24afce2
0905dea
d3760a6
465ddfd
c6f74f1
2cc0d96
a241222
4ee978c
4559afa
75243e0
839794a
61a9548
eb7c0d3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,7 +8,7 @@ public override void InitializeAcademy() | |
| Monitor.verticalOffset = 1f; | ||
| Physics.defaultSolverIterations = 12; | ||
| Physics.defaultSolverVelocityIterations = 12; | ||
| Time.fixedDeltaTime = 0.01333f; // (75fps). default is .2 (60fps) | ||
| Time.fixedDeltaTime = 0.01333f; // (75fps). default is .02 (60fps) | ||
|
||
| Time.maximumDeltaTime = .15f; // Default is .33 | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| using UnityEngine; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is directly modifying what unity calls
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That works for me too. Since this will only be used in our scenes, I'm less worried about the naming or making sure that it handles all possible cases. |
||
| using MLAgents; | ||
|
|
||
| public class SettingsOverrides : MonoBehaviour | ||
| { | ||
| // Original values | ||
| Vector3 m_OriginalGravity; | ||
| float m_OriginalFixedDeltaTime; | ||
| float m_OriginalMaximumDeltaTime; | ||
| int m_OriginalSolverIterations; | ||
| int m_OriginalSolverVelocityIterations; | ||
|
|
||
| public float gravityMultiplier = 1.0f; | ||
chriselion marked this conversation as resolved.
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if we should have gravity multiplier or gravity setting (with default at -9.81)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All of the scenes today use a multiplier (but FloatPropertiesChannel use the negative of the value) |
||
| public float fixedDeltaTime = .02f; | ||
chriselion marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| public float maximumDeltaTime = .33f; | ||
|
|
||
| [Header("Advanced physics settings")] | ||
| public int solverIterations = 6; | ||
| public int solverVelocityIterations = 1; | ||
|
|
||
| public void Awake() | ||
| { | ||
| // Save the original values | ||
| m_OriginalGravity = Physics.gravity; | ||
| Debug.Log($"Time.fixedDeltaTime = {Time.fixedDeltaTime} Time.maximumDeltaTime={Time.maximumDeltaTime}"); | ||
| m_OriginalFixedDeltaTime = Time.fixedDeltaTime; | ||
| m_OriginalMaximumDeltaTime = Time.maximumDeltaTime; | ||
| m_OriginalSolverIterations = Physics.defaultSolverIterations; | ||
| m_OriginalSolverVelocityIterations = Physics.defaultSolverVelocityIterations; | ||
|
|
||
| // Override | ||
| Physics.gravity *= gravityMultiplier; | ||
| Time.fixedDeltaTime = fixedDeltaTime; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most scenes only care about gravity, but Crawler and Walker override these deltaTime and solver iterations settings. |
||
| Time.maximumDeltaTime = maximumDeltaTime; | ||
| Physics.defaultSolverIterations = solverIterations; | ||
| Physics.defaultSolverVelocityIterations = solverVelocityIterations; | ||
|
|
||
| var academy = FindObjectOfType<Academy>(); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will eventually be replaced with singleton access. |
||
| academy.LazyInitialization(); | ||
|
|
||
| academy.FloatProperties.RegisterCallback("gravity", f => { Physics.gravity = new Vector3(0, -f, 0); }); | ||
| } | ||
|
|
||
| public void OnDestroy() | ||
| { | ||
| Physics.gravity = m_OriginalGravity; | ||
| Time.fixedDeltaTime = m_OriginalFixedDeltaTime; | ||
| Time.maximumDeltaTime = m_OriginalMaximumDeltaTime; | ||
| Physics.defaultSolverIterations = m_OriginalSolverIterations; | ||
| Physics.defaultSolverVelocityIterations = m_OriginalSolverVelocityIterations; | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.