Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  Get Particle Position
#7
(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);
Reply


Messages In This Thread
Get Particle Position - by Visitor245262 - 05-01-2021, 07:24 PM
RE: Get Particle Position - by josemendez - 05-01-2021, 07:50 PM
RE: Get Particle Position - by Visitor245262 - 05-01-2021, 09:32 PM
RE: Get Particle Position - by Visitor245262 - 06-01-2021, 01:49 AM
RE: Get Particle Position - by Visitor245262 - 12-01-2021, 07:20 PM
RE: Get Particle Position - by josemendez - 12-01-2021, 07:34 PM
RE: Get Particle Position - by Visitor245262 - 13-01-2021, 08:47 AM