13-01-2021, 08:47 AM
(This post was last modified: 13-01-2021, 11:09 AM by Visitor245262.)
(12-01-2021, 07:34 PM)josemendez Wrote: Hi there,
Can you share the exact code you're using for this? I can't seem to reproduce this behavior. GetParticlePosition() does not use any editor code so it should work regardless of the object being selected in editor or not.
Edit: here's the code I'm using for testing. Make sure to tell the solver you need the position values (by using Require/RelinquishRenderablePositions), or they won't be updated unless required by other scripts. This isn't needed in newer (>= 4.0) versions.
Thank you! It works now.
RequireRenderablePositions is what I was missing. My test video was just like the code used in the app to teleport a couple objects to some particle positions.
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Obi;
public class Test : MonoBehaviour
{
public ObiCloth cloth;
public Transform testObj;
public Text text;
public void Teleport() { // triggered by button
Vector3 pos = cloth.GetParticlePosition (0);
testObj.position = pos;
text.text = pos.ToString ("F4");
}
}
clothCtrlRt.position = innerLinerCloth.GetParticlePosition(50);
clothCtrlLt.position = innerLinerCloth.GetParticlePosition(51);