Obi Official Forum
Wrong Particle Position - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Wrong Particle Position (/thread-4381.html)



Wrong Particle Position - TryBios - 29-09-2024

Hi Everyone,

i have an Problem where i need the Particle Position of my Cable. It works fine when i have one Cable in the Scene. But as soon as i use more than one, somehow i get the same Particle from one Cable for all other Cables. I have a Script attached to every Cable and in this Script i search the specific Actor of every Gameobject and use those Particles (as you can see in the attachement). But somehow all the Cables use the same Particle of the first Cable which is in the Actor List. Hopefully i explained my Problem good enough if yall need more Information feel free to ask. Maybe im just dumb but i cant seem to find the Error.


RE: Wrong Particle Position - josemendez - 30-09-2024

Hi,

The documentation for GetParticlePosition() states:
Quote:Given a solver particle index, returns the position of that particle in world space.

The argument of the function is also called "solverIndex". You're passing an actor particle index instead, so it's always returning the position for the same particle.

You must pass an solver particle index instead, like so:

Code:
GetParticlePosition(actor.solverIndices[3]); // position of 3rd particle in the actor.

To understand the difference between actor and solver particle indices, see:
http://obi.virtualmethodstudio.com/manual/7.0/scriptingparticles.html

kind regards


RE: Wrong Particle Position - josemendez - 30-09-2024

As a side note, your code seems to assume the 3rd particle in the actor is the 3rd particle along the rope. This is usually not the case.


The reason is that when you change the length of the rope or tear/cut it, new particles may be added at any point along the rope (at the position of the cursor when resizing the rope, or at the position of the cut when cutting it). For instance, this rope:

(0)---(1)---(2)---(3)

may become this one when increasing its length using a cursor placed at particle 1 (two new particles with indices 4 and 5 are added to it):

(0)---(1)---(4)---(5)---(2)---(3)


So when reasoning about the length of a rope, you must not use particles but elements. See the manual for an in-depth explanation.

kind regards,