Obi Official Forum
Create rope 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: Create rope at runtime (/thread-1494.html)



Create rope at runtime - Kirian - 23-11-2019

I've looked at the examples and a couple of threads on this forum and it seems that the API has been updated but the docs/tutorials weren't.
In the version I have (and it's the latest from the Asset Store which is 5.0?) the RuntimeRopeGenerator has been commented out (ObiCurve is missing) and it's not even possible to follow tutorial because ObiCatmullRomCurve is also missing Confundido
Every other example on this forum seems to be using one of these classes so I'm in the dark here.
Maybe I'm not looking in the right places, can anyone tell me where can I find a working example?

What I'm trying to do is:
- create a rope on player input, the start point of the rope should follow a specified object in the scene
- the rope needs to extend forward until it reaches an obstacle
- attach the end of the rope to the obstacle and remove/cut it from the initial "spawner" object


RE: Create rope at runtime - jpalz - 25-11-2019

I also have the same question.
I want to create a leash (the same from a previous thread), but right I'm finding the following issues:

1- The documentation says that you need to call the coroutine GeneratePhysicRepresentationForMesh, yet apparently there's no such coroutine anymore.
2- To add a pin constraint, I needed to get the batch of pin constraint using rope.PinConstraints, yet PinConstraints doesn't seem to exist anymore, along with the class Obi.ObiPinConstraintBatch
3- If I wanted to get the last particle of a rope, I used the rope.UsedParticles variable, yet UsedParticles doesn't seem to exist anymore.

Congrats on the release of 5.0! Sonrisa


RE: Create rope at runtime - josemendez - 25-11-2019

(25-11-2019, 08:33 PM)jpalz Wrote: I also have the same question.
I want to create a leash (the same from a previous thread), but right I'm finding the following issues:

1- The documentation says that you need to call the coroutine GeneratePhysicRepresentationForMesh, yet apparently there's no such coroutine anymore.
2- To add a pin constraint, I needed to get the batch of pin constraint using rope.PinConstraints, yet PinConstraints doesn't seem to exist anymore, along with the class Obi.ObiPinConstraintBatch
3- If I wanted to get the last particle of a rope, I used the rope.UsedParticles variable, yet UsedParticles doesn't seem to exist anymore.

Congrats on the release of 5.0! Sonrisa

Updating the docs page for runtime actor creation tomorrow. Will let you know as soon as it is up!


RE: Create rope at runtime - josemendez - 26-11-2019

Hey,

As promised I updated the manual on this subject:
http://obi.virtualmethodstudio.com/tutorials/scriptingactors.html

I'd like to think that creating a rope at runtime (and any actor, for that matter) is much easier and concise in 5.0 than in previous versions.

Also, you can take a look at a pretty complete example in the GrapplingHook.cs file, included in the sample resources folder (/Obi/Samples/RopeAndRod/SampleResources/Scripts)

Let me know if you need help with it!  Tímido


RE: Create rope at runtime - Pingosso - 17-12-2019

(26-11-2019, 11:46 AM)josemendez Wrote: Hey,

As promised I updated the manual on this subject:
http://obi.virtualmethodstudio.com/tutorials/scriptingactors.html

I'd like to think that creating a rope at runtime (and any actor, for that matter) is much easier and concise in 5.0 than in previous versions.

Also, you can take a look at a pretty complete example in the GrapplingHook.cs file, included in the sample resources folder (/Obi/Samples/RopeAndRod/SampleResources/Scripts)

Let me know if you need help with it!  Tímido

Just a question to complete this subject: I make a Rope and a Solver in a project  and I export them to another project in prefab format, and I would like to implement the solver in a scene but i can't load it as an obisolver only as a gameobject....i think it will be identical for the rope. If you have a solution for that?

Thanks a lot in advance.

Sincerely,
Loïc


RE: Create rope at runtime - josemendez - 18-12-2019

(17-12-2019, 05:05 PM)Pingosso Wrote: Just a question to complete this subject: I make a Rope and a Solver in a project  and I export them to another project in prefab format, and I would like to implement the solver in a scene but i can't load it as an obisolver only as a gameobject....i think it will be identical for the rope. If you have a solution for that?

Thanks a lot in advance.

Sincerely,
Loïc

Hi!

Sorry, I don't understand the question.... what do you mean by "I can't load it as an obisolver only as a gameobject"?


RE: Create rope at runtime - Pingosso - 18-12-2019

(18-12-2019, 11:36 AM)josemendez Wrote: Hi!

Sorry, I don't understand the question.... what do you mean by "I can't load it as an obisolver only as a gameobject"?
Hi,

I created a prefab with an obisolver and I exported it to another project. In a script in the project I want to instantiate a solver with the prefab, not creating it by script, just instantiate a solver from the solver prefab I imported...and it failed....unity crashes.


I make some tests since yesterday, if i create a cube and add a script on it....in the script I create a public obisolver. I put the prefab of the solver in the script on the scene and in the start function I just instantiate the solver: ObiSolver.Instantiate(SolverFR, Vector3.zero, Quaternion.identity); Unity freeze....I can't instantiate a solver from a prefab.

I think the only solution is to create by script the solver and the ropes, but it's quite not the best way for me.

thanks a lot in advance if you have any solution for that.


RE: Create rope at runtime - josemendez - 18-12-2019

(18-12-2019, 12:21 PM)Pingosso Wrote: Hi,

I created a prefab with an obisolver and I exported it to another project. In a script in the project I want to instantiate a solver with the prefab, not creating it by script, just instantiate a solver from the solver prefab I imported...and it failed....unity crashes.


I make some tests since yesterday, if i create a cube and add a script on it....in the script I create a public obisolver. I put the prefab of the solver in the script on the scene and in the start function I just instantiate the solver: ObiSolver.Instantiate(SolverFR, Vector3.zero, Quaternion.identity); Unity freeze....I can't instantiate a solver from a prefab.

I think the only solution is to create by script the solver and the ropes, but it's quite not the best way for me.

thanks a lot in advance if you have any solution for that.

Hi,

Tested what I think you are doing (instantiating a GameObject with a solver component on it), works just fine for me. Actually, instantiating an object and creating it in code is the same thing internally, so there's no reason I can think of that would cause instatiation to crash/freeze.

Make sure the object you're instantiating does not contain itself the instantiation script. That would cause the instantiated object to instantiate itself again in Start() causing an infinite loop, and of course leading to a crash/freeze.


RE: Create rope at runtime - Pingosso - 18-12-2019

(18-12-2019, 12:48 PM)josemendez Wrote: Hi,

Tested what I think you are doing (instantiating a GameObject with a solver component on it), works just fine for me. Actually, instantiating an object and creating it in code is the same thing internally, so there's no reason I can think of that would cause instatiation to crash/freeze.

Make sure the object you're instantiating does not contain itself the instantiation script. That would cause the instantiated object to instantiate itself again in Start() causing an infinite loop, and of course leading to a crash/freeze.

I surely make a mistake but I don't see it...

My script that make unity crashed:
Object prefab = BundleManager.Get3DPrefab("Obi Solver");
ObiSolver SolverFR = GameObject.Instantiate(prefab) as ObiSolver;

with Get3DPrefab:
public static GameObject Get3DPrefab(string name)
    {
        GameObject go = Instance._bundle3D.LoadAsset(name, typeof(GameObject)) as GameObject;
        if (go == null)
            Debug.LogError("Cannot load or find asset " + name + " in 3D bundle");

        return go;
    }

And the prefab I tried to instantiate:
[Image: 191218010105578823.png]

Thanks a lot Jose


RE: Create rope at runtime - Pingosso - 18-12-2019

(18-12-2019, 12:57 PM)Pingosso Wrote: I surely make a mistake but I don't see it...

My script that make unity crashed:
Object prefab = BundleManager.Get3DPrefab("Obi Solver");
ObiSolver SolverFR = GameObject.Instantiate(prefab) as ObiSolver;

with Get3DPrefab:
public static GameObject Get3DPrefab(string name)
    {
        GameObject go = Instance._bundle3D.LoadAsset(name, typeof(GameObject)) as GameObject;
        if (go == null)
            Debug.LogError("Cannot load or find asset " + name + " in 3D bundle");

        return go;
    }

And the prefab I tried to instantiate:
[Image: 191218010105578823.png]

Thanks a lot Jose

Ok I find the problem comes from the updater which causes an infinite loop when instantiate, you're right