Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Automatically set control points to particle attachments
#1
Hi,

I'm only just starting using Obi Rope. I'm trying to set up a rope between the ground and a balloon going up. I set everything up and it seems to wrok but I was expecting the rope to automatically place itself so that its preset control points (start and end in the case of the long cable) would automatically position themselves to where the particle attachments are set. It's kind of tedious to have to do it manually. 

Also, I was thinking about dynamically spawning some ropes between two points at runtime. I expect to be able to set values on the positions[] array of the obi rope so that its 2 preset control points are at either attach points I choose. Will that affect the obiropeblueprint? Is it possible to set the positions for the instance of that obi rope and not the blueprints? This would obviously be a problem since the ropes will have varying lengths and positions and I wouldn't want to have to instantiate new blueprints everytime.

What is the suggested approach here?

Thank you!

- Fred
Reply
#2
(18-05-2020, 03:53 PM)FredTuna Wrote: Hi,

I'm only just starting using Obi Rope. I'm trying to set up a rope between the ground and a balloon going up. I set everything up and it seems to wrok but I was expecting the rope to automatically place itself so that its preset control points (start and end in the case of the long cable) would automatically position themselves to where the particle attachments are set. It's kind of tedious to have to do it manually. 

Also, I was thinking about dynamically spawning some ropes between two points at runtime. I expect to be able to set values on the positions[] array of the obi rope so that its 2 preset control points are at either attach points I choose. Will that affect the obiropeblueprint? Is it possible to set the positions for the instance of that obi rope and not the blueprints? This would obviously be a problem since the ropes will have varying lengths and positions and I wouldn't want to have to instantiate new blueprints everytime.

What is the suggested approach here?

Thank you!

- Fred


Hi Fred,

Particle attachments work the other way around: the particles are attached at their current position, relative to the attachment targets (the objects they're attached to). It is necessary to do it this way to ensure no sudden energy spikes are caused by overstretching/compressing the rope, which is what would happen if you forced the ends of the rope to arbitrary positions in a single frame. Picture what would happen if you placed two objects 6 meters apart from each other, and attached the ends of a 2 meter rope to them: On play, they would be launched towards each other or the rope would break (if tearable).

You have an example of spawning a rope between two points at runtime in the RopeGrapplingHook sample scene. See /Obi/Samples/RopeAndRod/SampleResources/Scripts/GrapplingHook.cs.

Quote:I expect to be able to set values on the positions[] array of the obi rope so that its 2 preset control points are at either attach points I choose. Will that affect the obiropeblueprint?

No it won't. When you instantiate a blueprint, the particle positions of the blueprint are copied to the solver arrays, from then on the instance and the blueprint are independent. In this regard, blueprints work just like prefabs.

Quote:This would obviously be a problem since the ropes will have varying lengths and positions and I wouldn't want to have to instantiate new blueprints everytime.

To define a rope, you need to define its path (shape and length). To do this you use a blueprint. Blueprints can be created at runtime, and have zero overhead. They're simply containers for particle data, so don't be afraid to create as many as you need. The advantage of blueprints versus storing rope shape in each individual rope is that you can share blueprints among multiple ropes, reducing both the amount of work you have to do and the memory used.
Reply
#3
Thanks for the quick answer!

For the attach points being set, that makes sense. For that case however, I'm setting a rope in a prefab (not at runtime). And I was looking for a way to set the position of that rope to its current attach points as a shortcut to having to manually move the control points. Even being able to manually set the position could be handy so I could just copy paste the position of the transforms I chose as attach points.
Reply
#4
(18-05-2020, 04:25 PM)FredTuna Wrote: Thanks for the quick answer!

For the attach points being set, that makes sense. For that case however, I'm setting a rope in a prefab (not at runtime). And I was looking for a way to set the position of that rope to its current attach points as a shortcut to having to manually move the control points. Even being able to manually set the position could be handy so I could just copy paste the position of the transforms I chose as attach points.

Setting attachment points manually is not a good idea, not at runtime, not in a prefab, for the same reason I outlined. Since they're calculated at bind time (Awake()) to avoid unphysical effects, whatever point you place the control point at will be used as attachment point.

Wouldn't snapping control points to a specific part of the target object suffice? Note that Unity's built-in snap tools (snap to vertex, snap to collider surface) do work with control point gizmos.
Reply