18-05-2020, 04:05 PM
(This post was last modified: 18-05-2020, 04:11 PM by josemendez.)
(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.