Hello everyone, I want to know if my ropes are crossing, for that I want to check the position of the leftmost and rightmost points of my rope, how can I access all the points of my rope? I tried to get them through ObiRopeBlueprints points array, but nothing came of it, it displays the length of 0. Thanks
Help ObiRope Points
|
19-10-2021, 10:50 AM
(19-10-2021, 10:26 AM)Matbee Wrote: Hello everyone, I want to know if my ropes are crossing, for that I want to check the position of the leftmost and rightmost points of my rope, how can I access all the points of my rope? I tried to get them through ObiRopeBlueprints points array, but nothing came of it, it displays the length of 0. Thanks Hi there, Blueprints are similar to prefabs: they're just "instructions" to build (instantiate) a rope. At runtime, particle data is contained in the solver. Check out the manual's page for particle scripting, let me know if you have further questions: http://obi.virtualmethodstudio.com/manua...icles.html (19-10-2021, 10:26 AM)Matbee Wrote: Hello everyone, I want to know if my ropes are crossing, for that I want to check the position of the leftmost and rightmost points of my rope, how can I access all the points of my rope? I tried to get them through ObiRopeBlueprints points array, but nothing came of it, it displays the length of 0. ThanksCan't I get the global position of a particle in space? And in general, if, for example, I have a very small value for the number of particles, how can I get, for example, a point from the middle of the rope? (19-10-2021, 10:26 AM)Matbee Wrote: Hello everyone, I want to know if my ropes are crossing, for that I want to check the position of the leftmost and rightmost points of my rope, how can I access all the points of my rope? I tried to get them through ObiRopeBlueprints points array, but nothing came of it, it displays the length of 0. Thanks _rope.solver.actors[0].particleCount. I got the number of particles of the actor, but the list of all particles how can i get?
19-10-2021, 11:24 AM
(This post was last modified: 19-10-2021, 11:25 AM by josemendez.)
(19-10-2021, 11:00 AM)Matbee Wrote: Can't I get the global position of a particle in space? Yes of course! you can express particle data in any space you'd like, including world space. Just use Unity's TransformPoint/Vector/Direction methods: https://docs.unity3d.com/ScriptReference...Point.html (19-10-2021, 11:00 AM)Matbee Wrote: And in general, if, for example, I have a very small value for the number of particles, how can I get, for example, a point from the middle of the rope? You can just take the element at the middle of the rope, and get either particle at its ends. The following code would return the position of the particle in the middle, expressed in world space: Code: int particleIndex = rope.elements[rope.elements.Count/2].particle1;
19-10-2021, 11:24 AM
(19-10-2021, 10:50 AM)josemendez Wrote: Hi there,Oops, I accidentally replied to my own message) . _rope.solver.actors[0].particleCount. I got the number of particles of the actor, but the list of all particles how can i get?
19-10-2021, 11:27 AM
(This post was last modified: 19-10-2021, 11:28 AM by josemendez.)
(19-10-2021, 11:24 AM)Matbee Wrote: Oops, I accidentally replied to my own message) . From the example in the manual: Code: // Iterate over all particles in an actor: For instance, to print the solver-space position of all particles (including inactive ones): Code: for (int i = 0; i < actor.solverIndices.Length; ++i)
19-10-2021, 11:28 AM
(19-10-2021, 11:24 AM)josemendez Wrote: Yes of course! you can express particle data in any space you'd like, including world space. Just use Unity's TransformPoint/Vector/Direction methods:Do I understand correctly that each rope element contains 2 particles? Particle1 and particle2?
19-10-2021, 11:29 AM
(19-10-2021, 11:29 AM)josemendez Wrote: Correct. Each element is an "edge" joining 2 particles together, like this:I got it to display several different positions for all particles, but most of the particles have the same position as in the screenshot below I also created a small sphere at each position, as you can see, some spheres were created at the correct position, but most of them were created at the point (0,0,1.8) (19-10-2021, 11:29 AM)josemendez Wrote: Correct. Each element is an "edge" joining 2 particles together, like this:
19-10-2021, 12:02 PM
(This post was last modified: 19-10-2021, 12:05 PM by josemendez.)
(19-10-2021, 11:47 AM)Matbee Wrote: I got it to display several different positions for all particles, but most of the particles have the same position as in the screenshot below Yes, those are the pooled (inactive) particles. Quoting myself: Quote:For instance, to print the solver-space position of all particles (including inactive ones): A certain amount of extra particles are preallocated when you create a rope blueprint. These are collectively referred to as the particle "pool", and start out inactive (invisible, and not used in the simulation). If you do not plan on resizing or cutting the rope at runtime, you can set the blueprint's pool size to zero. No inactive particles will be added to the rope. The reason for preallocating particles and activating/deactivating them instead of just creating/destroying particles at runtime is -as with most pooling strategies in Unity- to avoid runtime allocation and minimize garbage collection. See: http://obi.virtualmethodstudio.com/manua...setup.html Quote:Pooled particles: Assuming you do have a non-empty pool, if you want to only get the active particles you should do: Code: for (int i = 0; i < actor.activeParticleCount; ++i) |
« Next Oldest | Next Newest »
|