Posts: 21
Threads: 8
Joined: Jun 2020
Reputation:
0
Using Unity 2020.1.15f1 with Obi Cloth v. 5.6.2.
Continuation of the project including Final IK in forum thread thread link. Everything simulating correctly in the editor as expected, but as soon as I export a PC build of the scene, there is no cloth simulation happening at all.
As a system test, I've exported the example scene "CharacterCloth" and it works in a build exactly the same way as in the editor.
What elements could contribute to the cloth not being simulated while in a build, but appearing fine in the editor. I suspect this this is a simple setting, but I cannot find a suggestion in the user docs.
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
28-12-2020, 05:18 PM
(This post was last modified: 28-12-2020, 05:33 PM by josemendez.)
(25-12-2020, 12:47 AM)fluidman84 Wrote: Using Unity 2020.1.15f1 with Obi Cloth v. 5.6.2.
Continuation of the project including Final IK in forum thread thread link. Everything simulating correctly in the editor as expected, but as soon as I export a PC build of the scene, there is no cloth simulation happening at all.
As a system test, I've exported the example scene "CharacterCloth" and it works in a build exactly the same way as in the editor.
What elements could contribute to the cloth not being simulated while in a build, but appearing fine in the editor. I suspect this this is a simple setting, but I cannot find a suggestion in the user docs.
Make sure FinalIK and Obi are being updated in the correct order: FIK first, then Obi. By default final ik is updated in LateUpdate, so it will be the other way around. You want bone posituons adjusted by Final IK before Obi feeds them into the cloth simulation.
Also keep in mind that the order in which Unity calls FixedUpdate(), Update() and LateUpdate() methods for different components is essentially random. So if you were to update Obi in LateUpdate() by using ObiLateUpdater, (or FinalIK in FixedUpdate, leaving Obi in its own FixedUpdate()) things could work well in-editor but not in standalone or vice-versa. You’d be relying on pure luck, as you leave it up to Unity to call Obi’s FixedUpdate or FIK’s FixedUpdate() first.
You need to be explicit about the order in which you want things to happen during your frame. So, update FinalIK and Obi explicitly in a single FixedUpdate() call.
Posts: 21
Threads: 8
Joined: Jun 2020
Reputation:
0
My apologies, but I'm not finding the Obi solver manual update methods as I am the Final IK examples for disabling / enabling. I've tried this, but it does not appear to have solved the issue.
Code: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RootMotion.FinalIK;
using Obi;
public class IK_LateUpdate : MonoBehaviour
{
// Array of IK components that you can assign from the inspector.
// IK is abstract, so it does not matter which specific IK component types are used.
public IK[] components;
public ObiFixedUpdater obifixedupdater;
void Start()
{
// Disable all the IK components so they won't update their solvers. Use Disable() instead of enabled = false, the latter does not guarantee solver initiation.
foreach (IK component in components) component.enabled = false;
ObiProfiler.DisableProfiler();
}
void FixedUpdate()
{
// Updating the IK solvers in a specific order.
foreach (IK component in components) component.GetIKSolver().Update();
ObiProfiler.EnableProfiler();
}
}
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
29-12-2020, 09:26 AM
(This post was last modified: 29-12-2020, 09:40 AM by josemendez.)
(29-12-2020, 01:00 AM)fluidman84 Wrote: My apologies, but I'm not finding the Obi solver manual update methods as I am the Final IK examples for disabling / enabling. I've tried this, but it does not appear to have solved the issue.
Code: using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RootMotion.FinalIK;
using Obi;
public class IK_LateUpdate : MonoBehaviour
{
// Array of IK components that you can assign from the inspector.
// IK is abstract, so it does not matter which specific IK component types are used.
public IK[] components;
public ObiFixedUpdater obifixedupdater;
void Start()
{
// Disable all the IK components so they won't update their solvers. Use Disable() instead of enabled = false, the latter does not guarantee solver initiation.
foreach (IK component in components) component.enabled = false;
ObiProfiler.DisableProfiler();
}
void FixedUpdate()
{
// Updating the IK solvers in a specific order.
foreach (IK component in components) component.GetIKSolver().Update();
ObiProfiler.EnableProfiler();
}
}
In your code, you’re just enabling/disabling Obi’s built in profiler. Needless to say that won’t update the simulation. (Or profile it, as there’s nothing to profile there )
You can derive from the ObiUpdater class to update Obi whenever you want, as suggested in thr manual:
http://obi.virtualmethodstudio.com/tutor...aters.html
To do this, just look up ObiUpdater in the API docs:
http://obi.virtualmethodstudio.com/api.html
You'll see it has several methods to advance the simulation: BeginStep, Substep, EndStep, and Interpolate. You can also check the different existing subclasses of ObiUpdater (ObiFixedUpdater, ObiLateUpdater, etc) for examples on how/when to call these methods. The typical pattern would be:
Code: BeginStep();
Substep();
Substep();
.
.
.
Substep();
EndStep();
Interpolate();
So: one call to BeginStep() (performs collision detection and clears up cached data), one or more calls to Substep() (advances simulation), one call to EndStep(); (calls collision callbacks) and one call to Interpolate(); (interpolates physics state and triggers rendering).
The simplest thing for you to do is to just make a copy of ObiFixedUpdater, and then insert the FinalIK update code
in the appropiate place.
Note this isn’t the only possible solution. You just need things to update in a specific order, so you can also use Unity’s script execution order to explicitly set the order in which components should be updated, instead of writing a single component that updates both Obi and FinalIK. See: https://docs.unity3d.com/Manual/class-MonoManager.html
Posts: 21
Threads: 8
Joined: Jun 2020
Reputation:
0
30-12-2020, 10:47 PM
(This post was last modified: 30-12-2020, 10:54 PM by fluidman84.
Edit Reason: Fixed proposed code
)
Thank you Jose for this detailed response. I've created 2 different Final IK Characters to test this on. One Character contains the clothing skinned on the base character mesh and the other the clothing is a separate object from the base mesh and copies the bones from the base character to deform. In both systems, the clothing behaves as expected in the editor and then has no simulation in the build (but does still deform with the IK skele).
The FixedUpdate method to my modified Updater are as follows:
Code: private void FixedUpdate()
{
// Updating the IK solvers in a specific order.
foreach (IK ik in IKComponents)
{
ik.GetIKSolver().Update();
}
ObiProfiler.EnableProfiler();
Physics.autoSimulation = !substepUnityPhysics;
BeginStep(Time.fixedDeltaTime);
float substepDelta = Time.fixedDeltaTime / (float)substeps;
// Divide the step into multiple smaller substeps:
for (int i = 0; i < substeps; ++i)
{
// Simulate Obi:
Substep(substepDelta);
// Simulate Unity physics:
if (substepUnityPhysics)
Physics.Simulate(substepDelta);
}
EndStep(substepDelta);
ObiProfiler.DisableProfiler();
accumulatedTime -= Time.fixedDeltaTime;
}
I've tried placing the Final IK Solver as several places in the ObiFixedUpdater, but the result is always the same in builds.
Posts: 6,322
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
30-12-2020, 11:56 PM
(This post was last modified: 31-12-2020, 12:05 AM by josemendez.)
(30-12-2020, 10:47 PM)fluidman84 Wrote: Thank you Jose for this detailed response. I've created 2 different Final IK Characters to test this on. One Character contains the clothing skinned on the base character mesh and the other the clothing is a separate object from the base mesh and copies the bones from the base character to deform. In both systems, the clothing behaves as expected in the editor and then has no simulation in the build (but does still deform with the IK skele).
The FixedUpdate method to my modified Updater are as follows:
Code: private void FixedUpdate()
{
// Updating the IK solvers in a specific order.
foreach (IK ik in IKComponents)
{
ik.GetIKSolver().Update();
}
ObiProfiler.EnableProfiler();
Physics.autoSimulation = !substepUnityPhysics;
BeginStep(Time.fixedDeltaTime);
float substepDelta = Time.fixedDeltaTime / (float)substeps;
// Divide the step into multiple smaller substeps:
for (int i = 0; i < substeps; ++i)
{
// Simulate Obi:
Substep(substepDelta);
// Simulate Unity physics:
if (substepUnityPhysics)
Physics.Simulate(substepDelta);
}
EndStep(substepDelta);
ObiProfiler.DisableProfiler();
accumulatedTime -= Time.fixedDeltaTime;
}
I've tried placing the Final IK Solver as several places in the ObiFixedUpdater, but the result is always the same in builds.
I’m unable to reproduce this behavior. Both ik and cloth work fine on the build for me. What platform are you building for, and what solver backend are you using? (Oni or Burst)?
Also, any errors in the build’s log?
Posts: 21
Threads: 8
Joined: Jun 2020
Reputation:
0
I decided to simply rebuild the Final IK rig with the custom updater in the CharacterCloth Scene that you were kind enough to provide with the Obi Cloth package. When doing that, everything works as expected in builds, so it must be something incorrectly setup in my scene file.
Slightly frustrating to not be able to pinpoint the exact issue that's causing the problem in that scene, but I may track it down later if I have some time.
In any case, everything is looking good and I sincerely appreciate your valuable time to help me troubleshoot my specific utilization of it!!
|