Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Mesh Flies away on Simulation
#1
Hi,

I am currently making a simple mesh work with the cloth simulation using custom meshes made through unity. The mesh I am currently using is extremely simple of two rectangles that are stitched together using Obistitcher. The problem I am having however is  that the mesh flies away immediately after I start simulating (I am also using a custom obiupdater to handle the simulation) and I am not sure what is causing this. 

Here is the example of whats occuring https://youtu.be/xJC8gUavDDA


Custom ObiUpdater 
Code:
private void Awake()
        {
            _currentSimulationTime = 0;


            if (solvers == null)
                solvers.Add(gameObject.GetComponent<ObiSolver>());
           
        }

        [ContextMenu("Toggle Simulation")]
        public void ToggleSimulate() => isSimulating = !isSimulating;

        private void FixedUpdate()
        {
            if (!isSimulating)
                return;
           
            if (_currentSimulationTime >= _simulateTime)
            {
                isSimulating = false;
                return;
            }
           
            BeginStep(Time.fixedDeltaTime);

            float substepDelta = Time.fixedDeltaTime / _substeps;

            for (int i = 0; i < _substeps; ++i)
                Substep(Time.fixedDeltaTime,substepDelta,_substeps - i);
           
            EndStep(substepDelta);


            Interpolate(2, 100);
            _currentSimulationTime += Time.fixedDeltaTime;
        }

        private void Update()
        {
            if (!isSimulating)
            {
                if (_currentSimulationTime >= _simulateTime)
                {
                    _currentSimulationTime = 0f;
                    gameObject.GetComponent<MeshController>().BakeMesh();
                }
                
                return;
            }
           
            if (_currentSimulationTime >= _simulateTime)
            {
                isSimulating = false;
                return;
            }
           
            ObiProfiler.EnableProfiler();
            Interpolate(Time.fixedDeltaTime,_currentSimulationTime);
            ObiProfiler.DisableProfiler();

            _currentSimulationTime += Time.deltaTime;

        }
       
    }
Reply


Messages In This Thread
Mesh Flies away on Simulation - by Biggerest - 05-12-2021, 07:48 PM
RE: Mesh Flies away on Simulation - by josemendez - 06-12-2021, 11:15 AM
RE: Mesh Flies away on Simulation - by Biggerest - 08-12-2021, 05:44 PM
RE: Mesh Flies away on Simulation - by josemendez - 10-12-2021, 09:42 AM