![]() |
Help ObiRope Points - 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 ObiRope Points (/thread-3139.html) |
RE: ObiRope Points - Matbee - 19-10-2021 (19-10-2021, 12:02 PM)josemendez Wrote: Yes, those are the pooled (inactive) particles. Quoting myself: In fact, is my object Obi Rope the same actor? The index of the actor is the same Obi Rope as the index in the hierarchy ?? PhoneRope1 this is essentially actors[0] PhoneRope2 this is essentially actors[1]???? Thanks [attachment=1135] RE: ObiRope Points - josemendez - 19-10-2021 (19-10-2021, 01:26 PM)Matbee Wrote: In fact, is my object Obi Rope the same actor? The index of the actor is the same Obi Rope as the index in the hierarchy ?? No, actors aren't added to the solver in the same order they appear in the hierarchy. They are added in the order their Start() methods are called, so the exact order is undefined (because the order in which Unity calls Start for different objects is also undefined). Why do you want to access the solver's internal actor array? you already have a reference to each rope, right? ropes are actors, so you can just do: PhoneRope1.solverIndices, PhoneRope1.activeParticleCount, etc. ObiActor is just the base class for anything that's made of particles, and that includes ropes. RE: ObiRope Points - Matbee - 19-10-2021 (19-10-2021, 01:30 PM)josemendez Wrote: No, actors aren't added to the solver in the same order they appear in the hierarchy. They are added in the order their Start() methods are called, so the exact order is undefined (because the order in which Unity calls Start for different objects is also undefined).Is it possible to somehow get a list of all the ropes in the solver? RE: ObiRope Points - josemendez - 19-10-2021 (19-10-2021, 02:36 PM)Matbee Wrote: Is it possible to somehow get a list of all the ropes in the solver? If there’s only ropes in the solver, that would be the actors array you referred to in the previous question. If there’s other kinds of actors (rods, for instance), just check the type of each one and discard anything that is not a rope. This assumes that you understand inheritance/polimorphism in C#, if that’s not the case I’d recommend reading about the subject and getting your C# up to speed. RE: ObiRope Points - Matbee - 19-10-2021 (19-10-2021, 02:50 PM)josemendez Wrote: If there’s only ropes in the solver, that would be the actors array you referred to in the previous question. If there’s other kinds of actors (rods, for instance), just check the type of each one and discard anything that is not a rope.Yes, there are only ropes in my solver, but I want to get them in the correct order RE: ObiRope Points - josemendez - 19-10-2021 (19-10-2021, 02:52 PM)Matbee Wrote: Yes, there are only ropes in my solver, but I want to get them in the correct order Why not using Unity’s methods then? GetChild(n) will give you the nth children of a transform, in the same order they appear in the hierarchy. https://docs.unity3d.com/ScriptReference/Transform.GetChild.html RE: ObiRope Points - Matbee - 19-10-2021 (19-10-2021, 03:02 PM)josemendez Wrote: Why not using Unity’s methods then? GetChild(n) will give you the nth children of a transform, in the same order they appear in the hierarchy.I will get ObiRope objects, I will have access to the solver, but in the actors, the order of the ropes may still be wrong RE: ObiRope Points - josemendez - 19-10-2021 (19-10-2021, 04:23 PM)Matbee Wrote: I will get ObiRope objects, I will have access to the solver, but in the actors, the order of the ropes may still be wrong Why are you concerned about the order in which the ropes are internally added to the solver? Can’t really think of a reason why it would matter at all. If you want them in the order in which they appear in the scene hierarchy, Unity already gives you that. RE: ObiRope Points - Matbee - 20-10-2021 (19-10-2021, 04:36 PM)josemendez Wrote: Why are you concerned about the order in which the ropes are internally added to the solver? Can’t really think of a reason why it would matter at all.can i somehow limit the length of the rope? (19-10-2021, 04:36 PM)josemendez Wrote: Why are you concerned about the order in which the ropes are internally added to the solver? Can’t really think of a reason why it would matter at all.since other objects are associated with this actor, and it is necessary that the order is observed in order to animate the desired objects after working with a certain rope RE: ObiRope Points - josemendez - 20-10-2021 (20-10-2021, 09:23 AM)Matbee Wrote: can i somehow limit the length of the rope? Don't really understand this question... ropes already have a limited length, their rest length. They won't exceed this length (that is, unless you attach their ends to transforms using static attachments, in that case you would be forcing them to stretch). (20-10-2021, 09:23 AM)Matbee Wrote: since other objects are associated with this actor, and it is necessary that the order is observed in order to animate the desired objects after working with a certain rope Still don't understand....why not using the order in which they appear in the hierarchy? the "solver.actors" array in the solver contains *exactly* the same data as Unity's transform hierarchy, but in a random order as it's basically a set: order does not matter. Unity will give them to you ordered, which is what you need right? why access them trough the actors array? ![]() As I mentioned before, transform.GetChild() will give them to you in the order they appear in the scene hierarchy. So if you only have ropes inside the solver, you can access them ordered like this: Code: var rope1 = solver.transform.GetChild(0).GetComponent<ObiRope>(); // first rope If you have other objects mixed in, simply check whether or not they have a rope component. |