Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
RESET Obi Softbody
#4
Thank you so much for the quick reply and your code - it seems to work! BUT! Only thing, since adding the script, Unity editor keeps crashing on me, also it crashed during build. After that the build succeeded, but the app crashed on my phone. I troubleshot it multiple times and this behavior only happens when this script is present. Maybe any clue why this could be?

As to your question, this is GPT-4s best attempt of resetting the softbody (which also didn't work, after hours of iterating):


Code:
using UnityEngine;
using Obi;

[RequireComponent(typeof(ObiSoftbody))]
public class ResetObiSoftbody : MonoBehaviour {

    ObiSoftbody softbody;
    Vector4[] originalPositions;

    void Awake(){
        softbody = GetComponent<ObiSoftbody>();
        originalPositions = new Vector4[softbody.solverIndices.Length];

        // Store the original positions
        for (int i = 0; i < softbody.solverIndices.Length; ++i){
            int solverIndex = softbody.solverIndices[i];
            originalPositions[i] = softbody.solver.positions[solverIndex];
        }
    }

    public void ResetToOriginalPosition(){
        // Reset the positions
        for (int i = 0; i < softbody.solverIndices.Length; ++i){
            int solverIndex = softbody.solverIndices[i];
            softbody.solver.positions[solverIndex] = originalPositions[i];
        }
    }
}
Reply


Messages In This Thread
RESET Obi Softbody - by swancollective - 22-06-2023, 08:25 PM
RE: RESET Obi Softbody - by swancollective - 23-06-2023, 11:17 AM
RE: RESET Obi Softbody - by josemendez - 23-06-2023, 02:19 PM
RE: RESET Obi Softbody - by swancollective - 23-06-2023, 06:00 PM
RE: RESET Obi Softbody - by josemendez - 23-06-2023, 06:42 PM
RE: RESET Obi Softbody - by swancollective - 24-06-2023, 11:52 AM
RE: RESET Obi Softbody - by josemendez - 24-06-2023, 02:48 PM
RE: RESET Obi Softbody - by swancollective - 25-06-2023, 10:15 AM
RE: RESET Obi Softbody - by josemendez - 25-06-2023, 11:06 AM
RE: RESET Obi Softbody - by swancollective - 25-06-2023, 12:39 PM
RE: RESET Obi Softbody - by swancollective - 03-07-2023, 07:20 AM
RE: RESET Obi Softbody - by spikebor - 09-05-2024, 06:12 AM