Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Instantiate from Prefab - Each end into position
#1
Sonrisa 
Hey feel free to send me to other places to do more reading. Or re-reading. I may have missed the answer elsewhere! But I have been struggling for a week now.

I have a similar goal to the user in this thread although I'm not getting a flat crash. Sometimes I get a performance bog down and THEN crash... Anyway. 

Idea  TL;DR I am simply trying to spawn a rope from a prefab, in precise position, but it keeps tearing.

Huh The Problem, longer version: 
  • I have prefab of a rope just the way I like it. Would rather not generate the rope from code (using the stuff in the Helper script). Anyway, it is in a gameobject with its own solver. 
  • And most importantly, this prefab rope has two gameobject children: call them BlockA and BlockB. These blocks represent the start and end of the rope. Each particle tip of the rope is constrained to their blocks. So far so straightforward.
  • The idea is... tie TWO objects together easily. By attaching / childing the blocks to those objects. I can use the ObiCursor to changelength no problem.
  • In other words... I aim to create a function that accepts two vector3 positions and then creates an appropriately sized rope between them. Or in other words again, imagine two objects floating around, but then when the user presses SPACEBAR the two objects have the prefab rope spawned between them, each with a Block childed' to it.

Ángel
  1. First question: What do I need to watch out for? Surely connecting two objects at runtime is a somewhat common application of Obi Rope.
Spawning a rope prefab connecting two objects (mostly by managing Gameobject block ends) has proven difficult! I mean, I have learned in these forums (or, Taiga forums) I have to disable the actor to teleport rope. OK. And at one point I crashed my computer with one batch of code - and no, it wasn't using any WHILE loops  Triste  I think it was partly because I tried turning TEARABLE = false. But that's not the only reason my system bugged out I'm sure. It's not a parent/Child feedback thing either I don't think; because the Blocks do not REMAIN children in my code - they are parented away to OTHER objects. So they shouldn't be moving with the prefab anymore - which would move the rope - which would move the transform and cause vicious feedback I'm sure...

Anyway. I do think part of the problem is that I transform the ends of the rope in just a couple frames. I mean, I have to do this because I want the rope to spawn apparently instantaneously. Unfortunately right now I do this: (a) Spawn the rope in approximately the right space, but then (b) Quickly teleport the edges into position, and then the rope TEARS every time.

So...
      
     2. Second Question: Suppose I'm doing everything else right. But my rope is indeed being torn by the act of transforming the blocks to which its ends are constrained... is there another way to get each end immediately into their proper position? For that matter, I may need to iterate through each particle and specify its location - so the whole thing is in position... Is that it?

PS.
If you can see the picture attached, that might help. Note that the final position of the rope might mean using the ObiCursor real quick too. Because the desired length might be longer or shorter. But again, getting the correct length has not been much of a problem for me.
   

Any help would be appreciated.
Reply


Messages In This Thread
Instantiate from Prefab - Each end into position - by Jerth - 12-06-2018, 05:55 PM