Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Obi 7.0 ParticleAPI
#13
(10-06-2025, 10:26 AM)josemendez Wrote: Vector spaces are critical stuff to understand when working with any game engine, since all engines are full of them and use them constantly: object, local, world, camera, viewport, screen, etc. Unity has built-in methods to convert data between spaces. To convert a position from local to world space, use TransformPoint.

Here's your code after fixing all issues:

- Use world space for everything.
- Stop looping once you find a particle inside, don't overwrite a variable each iteration.
- Only check active particles.

Assuming crossArea.bounds is expressed in world space (it will if crossArea is a collider, as per the documentation), this will return true if any particle in the rope is inside the bounds, and false otherwise.


Code:
bool IsRopeInsideCrossArea()
    {
        if (rope.isLoaded)
        {
            for (int i = 0; i < rope.activeParticleCount; ++i)
            {
                int solverIndex = rope.solverIndices[i];
                Vector3 particlePos = rope.solver.transform.TransformPoint(rope.solver.positions[solverIndex]);
                Debug.Log($"particle {solverIndex} position {particlePos}");
          
                if (crossArea.bounds.Contains(particlePos))
                    return true;
            }
           
        }
        return false;
    }

Let me know if you need further help Sonrisa

You solved all my issues, thak you so much!
Reply


Messages In This Thread
Obi 7.0 ParticleAPI - by PlatonSk - 29-08-2024, 11:37 AM
RE: Obi 7.0 ParticleAPI - by goosejordan - 29-08-2024, 12:01 PM
RE: Obi 7.0 ParticleAPI - by josemendez - 29-08-2024, 12:02 PM
RE: Obi 7.0 ParticleAPI - by alicecatalano - 09-06-2025, 04:33 PM
RE: Obi 7.0 ParticleAPI - by josemendez - 10-06-2025, 06:23 AM
RE: Obi 7.0 ParticleAPI - by alicecatalano - 10-06-2025, 08:31 AM
RE: Obi 7.0 ParticleAPI - by josemendez - 10-06-2025, 08:47 AM
RE: Obi 7.0 ParticleAPI - by chenji - 10-06-2025, 09:40 AM
RE: Obi 7.0 ParticleAPI - by josemendez - 10-06-2025, 10:16 AM
RE: Obi 7.0 ParticleAPI - by alicecatalano - 10-06-2025, 10:18 AM
RE: Obi 7.0 ParticleAPI - by josemendez - 10-06-2025, 10:26 AM
RE: Obi 7.0 ParticleAPI - by alicecatalano - 12-06-2025, 09:19 AM
RE: Obi 7.0 ParticleAPI - by josemendez - 10-06-2025, 10:21 AM