Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Releasing softbody particles from anchor
#1
Following along the script example here:
Code:
using UnityEngine;
using System.Collections;
using Obi;

[RequireComponent(typeof(ObiActor))]
public class DistanceAnchor : MonoBehaviour {

    ObiActor actor;
    public Transform anchor;
    public float anchorRadius = 0.5f;

    void Awake(){
        actor = GetComponent<ObiActor>();
    }

    void Start(){
        if (actor.isLoaded){
            for (int i = 0; i < actor.solverIndices.Length; ++i){

                int solverIndex = actor.solverIndices[i];

                // if the particle is visually close enough to the anchor, fix it.
                if (Vector3.Distance(actor.GetParticlePosition(solverIndex), anchor.position)
                        < anchorRadius)
                {
                    actor.solver.velocities[solverIndex] = Vector3.zero;
                    actor.solver.invMasses[solverIndex] = 0;
                }
            }
        }
    }
}
From: http://obi.virtualmethodstudio.com/manua...icles.html

What is a good approach to later release the softbody particles from the anchor?
I tried saving a copy of `velocities` and `invMasses` prior to setting them to 0, and then restoring them on the actor's solver when some callback gets invoked. This did not seem to work.

or is there a way to disable gravity on the exclusively on the softbody particles?
Reply


Messages In This Thread
Releasing softbody particles from anchor - by blobman - 26-03-2023, 11:57 PM