Obi Official Forum
Help procedure control point does not spawn particle in correct place - 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: Help procedure control point does not spawn particle in correct place (/thread-4305.html)



procedure control point does not spawn particle in correct place - bugbeeb - 29-07-2024

I'm making something like a grappling hook, but I need to respawn the line each time it's triggered. To do this I modified some code from the obi grappling hook example where the blueprint is regenerated and I set the control points. However, the particles don't seem to spawn in the correct location. Here is the code to spawn the particles:

```
        var localPos = rope.solver.transform.InverseTransformPoint(transform.position);
        var characterLocalPos = rope.solver.transform.InverseTransformPoint(character.transform.position);

        rope.ropeBlueprint = null;

        var filter = ObiUtils.MakeFilter(0x0000FFFE, 0);
        blueprint.path.Clear();
        blueprint.path.AddControlPoint(characterLocalPos, Vector3.zero, Vector3.zero, Vector3.up, 1f, 0.1f, 1, filter, Color.white, "Start");
        blueprint.path.AddControlPoint(localPos, Vector3.zero, Vector3.zero, Vector3.up, 1f, 0.1f, 1, filter, Color.white, "End");
        blueprint.path.FlushEvents();
        yield return blueprint.Generate();

        rope.ropeBlueprint = blueprint;
```

But the first and last particles are noticebly off by the same amount whereas I would expect them to be located exactly at the transform positions specified in the blueprint. Am I doing something wrong here?


RE: procedure control point does not spawn particle in correct place - josemendez - 29-07-2024

Hi,

Maybe your solver's or your rope's transform are not at the correct position?

Like all blueprint data, the positions passed to AddControlPoint are expressed in the rope's local space. That specific sample scene you got the code from assumes the solver is placed at 0,0,0 (world's origin) and that the rope is placed at the character's position. If this is not your use case, you should account for any differences when calculating the control point's positions.

kind regards,


RE: procedure control point does not spawn particle in correct place - bugbeeb - 29-07-2024

(29-07-2024, 12:45 PM)josemendez Wrote: Hi,

Maybe your solver's or your rope's transform are not at the correct position?

Like all blueprint data, the positions passed to AddControlPoint are expressed in the rope's local space. That specific sample scene you got the code from assumes the solver is placed at 0,0,0 (world's origin) and that the rope is placed at the character's position. If this is not your use case, you should account for any differences when calculating the control point's positions.

kind regards,
Thank you