Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  How do I set a particle position at runtime ?
#4
(29-03-2020, 07:04 PM)slugGoddess Wrote: Hey Jose ! 
Thanks a lot for answering so quickly. 


I tried setting the position in FixedUpdate instead, but sadly, the particle just goes straight back to its initial position with each new frame.
I have drawn a gizmo on the position it was supposed to move to (the bottom one), and one at the position it's actually at: 

Code:
Gizmos.DrawSphere(this.rope.solver.positions[solverIndex], 0.1f);

Gizmos.DrawSphere(position, 0.1f);
[Image: screenshot043.jpg]
As you can see they don't quite match.

I feel like there is something I am missing. Am I supposed to push the modified data to the solver or anything similar?
Thank you in advance !  Sonrojado

Particle positions (and velocities, radii, ... all particle properties) are expressed in solver space. So if you pass a solver space position to Gizmos.Draw() (which by default expects data to be expressed in world space), the drawn position and the actual particle position won't match at all. You must express the position in world space before drawing it, or set Gizmos.matrix accordingly. See: https://docs.unity3d.com/ScriptReference...atrix.html

Setting particle positions in FixedUpdate() works just fine for me. Can you share your code?
Reply


Messages In This Thread
RE: How do I set a particle position at runtime ? - by josemendez - 29-03-2020, 07:12 PM