Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Instantiate from Prefab - Each end into position
#3
(12-06-2018, 06:58 PM)josemendez Wrote: Hi,

Imho your approach of using prefabs is fundamentally flawed: what happens if the objects you want to attach using the rope are further apart than the prefab rope's length? the rope will stretch instantaneously upon starting simulation, and will most likely tear apart (depending on your tear threshold). This will only work if the distance between the objects you want to attach is approximately the same as the rope length. It will also fail if the objects are in different positions than the rope's ends, as you'd need to move the rope particles around pretty quickly. It is much easier to procedurally generate your rope with the correct position/length right from the start.

Obi includes a sample script to do just this: procedurally create a rope between two transforms: /Obi/Scripts/Utils/ObiRopeHelper. It might prove useful.

You're right. The HELPER script was not as intimidating as I thought, and quite elegant. Thanks josemendez.

Corazón

A new problem I'm running into is that I crash my Unity (and computer lol) when I try to use an OFFSET on my constraints  Huh


Code:
constraintsBatch.AddConstraint(rope.UsedParticles - 1, targetCube.GetComponent<ObiCollider>(), Vector3.zero, 0f);


That works fine but if I replace "Vector3.zero" with a calculated offset... BAM.
Any tips off the bat??
Reply


Messages In This Thread
RE: Instantiate from Prefab - Each end into position - by Jerth - 16-06-2018, 03:03 AM