![]() |
Reset rope starting shape? - 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: Reset rope starting shape? (/thread-2044.html) |
Reset rope starting shape? - basilisk - 13-02-2020 I have a coiled rope that unwinds nicely when the rope is enabled. I want to have the rope reset to it's starting coiled shape every time I activate it. How to I reset the rope to it's original shape? RE: Reset rope starting shape? - josemendez - 13-02-2020 (13-02-2020, 12:18 PM)basilisk Wrote: I have a coiled rope that unwinds nicely when the rope is enabled. I want to have the rope reset to it's starting coiled shape every time I activate it. How to I reset the rope to it's original shape? All you need to do is set the solver's particle positions/velocities to the ones stored in the blueprint. If you're using a rod (which makes use of oriented particles), do the same with particle orientations/angular velocities. Only thing you need to be a bit careful with is converting the blueprint data (which is expressed in local space) to solver space. Like this: Code: void Reset(ObiActor actor) See: http://obi.virtualmethodstudio.com/tutorials/scriptingparticles.html RE: Reset rope starting shape? - basilisk - 13-02-2020 Thank you, this works. But oddly, I am getting an error... Code: NullReferenceException: Object reference not set to an instance of an object error at the line: Code: if (actor.isLoaded) The rope shape is still being reset like I want even with this null error, so it works but I'd like to eliminate the error. They way I've set it up is a public ObiActor myRope variable where I assign the rope GameObject in the editor, and when I want the rope to reset reset I pass myRope into... Code: void Reset(ObiActor actor) Any idea why this null error is happening? RE: Reset rope starting shape? - josemendez - 13-02-2020 (13-02-2020, 02:54 PM)basilisk Wrote: Thank you, this works. But oddly, I am getting an error... As far as your description goes, a null ref error in Code: if (actor.isLoaded) can only indicate that "actor" is null. Maybe try using Code: if (actor != null && actor.isLoaded) instead, if you plan on passing null sometimes? As to why is null being passed into the function, that's something I cannot know without looking at your actual code... RE: Reset rope starting shape? - basilisk - 13-02-2020 Sorry! Yep, it was completely my fault. Bad piece of code on my side. Thank you for your help. ObiRope is great! |