Following along the script example here:
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?
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;
}
}
}
}
}
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?