Obi Official Forum
Help Instantiating Ropes at runtime - 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 Instantiating Ropes at runtime (/thread-2530.html)



Instantiating Ropes at runtime - Eulenmensch - 09-10-2020

Hi, love the asset so far, great UX and really powerful!

I am doing fine with ropes that I author and place in the scene but am running into some issues/questions now that I'm attempting to instantiate them at runtime.

My usecase is that I have a Helium Balloon(rigidbody with up force applied) that spawns and attaches to other rigidbodies on collision. I want this attachment to be an Obi Rope to simulate the string of the balloon.
For that I would need to set the start and end nodes of a rope to the balloons position and the impact point respectively.

Do I need to create a blueprint at runtime for each of the ropes to do so? 

How do I know which index each particle group of a rope has?

Thanks for the great asset!


RE: Instantiating Ropes at runtime - josemendez - 09-10-2020

(09-10-2020, 12:48 PM)Eulenmensch Wrote: Hi, love the asset so far, great UX and really powerful!

I am doing fine with ropes that I author and place in the scene but am running into some issues/questions now that I'm attempting to instantiate them at runtime.

My usecase is that I have a Helium Balloon(rigidbody with up force applied) that spawns and attaches to other rigidbodies on collision. I want this attachment to be an Obi Rope to simulate the string of the balloon.
For that I would need to set the start and end nodes of a rope to the balloons position and the impact point respectively.

Do I need to create a blueprint at runtime for each of the ropes to do so? 

How do I know which index each particle group of a rope has?

Thanks for the great asset!

Hi there!

If you're going to create each rope at runtime, they will presumably have different lengths/shapes, so yes you should create a separate blueprint for each one. There's no downsides in doing this. Check out the included RopeGrapplingHook sample scene for some code that creates both blueprints and ropes programmatically (/Obi/Samples/RopeAndRod/SampleResources/Scripts/GrapplingHook.cs)

To retrieve the indices of the particles in a particle group, just do:
Code:
List<int> indices = rope.blueprint.groups[groupIndex].particleIndices;

In the case of ropes, particle groups only contain 1 particle each, so even though particleIndices is a List you can count on it having only one entry.

cheers!


RE: Instantiating Ropes at runtime - Eulenmensch - 09-10-2020

Hey, thanks for the quick reply!

Ok, that's super helpful, I'll get started on that.
Honestly one of the best assets I've used so far, so great job and thanks!