Help Pooled Objects Rope Position Bug?? - 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 Pooled Objects Rope Position Bug?? (/thread-3828.html) |
Pooled Objects Rope Position Bug?? - exWitcher - 01-04-2023 Hi, I have 2 game objects that are connected to each other with a rope and they have a parent object. Due to the mechanics of my game, I use this object by pulling it from the pool and sending it back to the pool. When I pull an object from the pool to use it a second time, the obi rope position comes at a completely different point and I can never fix it in runtime. Is there a restart function for ropes or solvers? I dont want to Instantiate new objects in runtime.. I can add videos or gifs if needed. But i could use an urgent help RE: Pooled Objects Rope Position Bug?? - josemendez - 01-04-2023 (01-04-2023, 04:18 PM)exWitcher Wrote: Hi, I have 2 game objects that are connected to each other with a rope and they have a parent object. Due to the mechanics of my game, I use this object by pulling it from the pool and sending it back to the pool. When I pull an object from the pool to use it a second time, the obi rope position comes at a completely different point and I can never fix it in runtime. Is there a restart function for ropes or solvers? I dont want to Instantiate new objects in runtime.. Hi! Actors in Obi (this includes ropes, rods, and basically any object made out of particles) do not have a position/orientation of their own, their transform values are only used for spawning the blueprint once the actor is created. The reason for this is that you can’t determine the placement of a deformable object using a single position/orientation. At runtime, each particle in the actor has its own position and orientation in the solver’s local space. So if you let the simulation run for a while they may end up far away from the objects’s transform. If you want to reset all particles in an actor to the position/orientation they had when the actor was created (that is, the ones stored in the actor’s blueprint) you can use actor.ResetParticles(). Kind regards, RE: Pooled Objects Rope Position Bug?? - exWitcher - 01-04-2023 (01-04-2023, 05:10 PM)josemendez Wrote: Hi! Hey, thanks for the answer I have tried rope.ResetParticles() before I post here but didn't work for me I called that function after I've pulled the object from pool (like it should be?) . I can see the blueprint line is correct and my ropes attached transforms are correct but it looks like it has different object to attached and acting its own. I have no idea whats happening (The second object from the pool actually the first one) RE: Pooled Objects Rope Position Bug?? - josemendez - 03-04-2023 (01-04-2023, 06:34 PM)exWitcher Wrote: Hey, thanks for the answer How have you implemented "pulling object from the pool"? Is it just enabling/disabling GameObjects? What's happening here is that particles are simulated in the solver's local space, not the rope's local space. So when you instantiate a rope, its particles appear in the position they had relative to the solver object when they were "alive" for the last time. This is explained in the docs: http://obi.virtualmethodstudio.com/manual/6.3/obisolver.html Quote:Solvers always perform the simulation in local space. This means that translating, rotating or scaling the solver will rigidly transform the simulation as a whole. You just need to move the particles back to the position they're supposed to be in when you take the object out of the pool. ResetParticles() should do the job, as long as it's called at the right moment. If I could take a look at your pooling code would make it easier to tell what's wrong. kind regards, |