Posts: 17
Threads: 4
Joined: Nov 2020
Reputation:
0
05-11-2020, 12:37 PM
(This post was last modified: 05-11-2020, 12:46 PM by canerozdemir.)
Hello,
So I am adding a rope by code and I am able to instantiate it to a degree. However, when the rope is created and after I attach the rope using ObiParticleAttachment it becomes unstable when I move either the end or the start point. It goes back and forth intensely. Attachment works fine, the problem is the intense stretch and I need to make the rope more stable.
Also, how can I set a target on the ObiParticleAttachment with code? I have a start and an end point on the blueprint and I added them by using code. However, I am not able to assign a target to ObiParticleAttachment and it asks for a Obi specific component.
Thank you.
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
05-11-2020, 12:47 PM
(This post was last modified: 05-11-2020, 12:51 PM by josemendez.)
(05-11-2020, 12:37 PM)canerozdemir Wrote: Hello,
So I am adding a rope by code and I am able to instantiate it to a degree. However, when the rope is created and after I attach the rope using ObiParticleAttachment it becomes unstable when I move either the end or the start point. It goes back and forth intensely.
Make sure you're not attaching the rope inside a collider. This will always cause instabilities, because the rope can't be simultaneously inside and outside a collider. See the last bit of: http://obi.virtualmethodstudio.com/tutor...aints.html
(05-11-2020, 12:37 PM)canerozdemir Wrote: Also, how can I set a target on the ObiParticleAttachment with code. I have a start and an end point on the blueprint and I added them by using code. However, I am not able to assign a target to ObiParticleAttachment.
There's not much involved in this. Attachments have a public "target" property that can you can get/set. So:
Code: attachment.target = //your target transform here
Posts: 17
Threads: 4
Joined: Nov 2020
Reputation:
0
05-11-2020, 01:01 PM
(This post was last modified: 05-11-2020, 01:03 PM by canerozdemir.)
(05-11-2020, 12:47 PM)josemendez Wrote: Make sure you're not attaching the rope inside a collider. This will always cause instabilities, because the rope can't be simultaneously inside and outside a collider. See the last bit of: http://obi.virtualmethodstudio.com/tutor...aints.html
There's not much involved in this. Attachments have a public "target" property that can you can get/set. So:
Code: attachment.target = //your target transform here
I will try and comment the result later on. Thank you. And I forgot to tell, I assign the target but I am not able to assign the end or the start point as a particle group. In the blueprint, those points do exist and I have them on my code. I have "start" and "end" as suggested on the official documentation. But I cant assign them by code so the Obi Particle Attachment doesn't work as expected.
One more question, how can I set the rope length when I move those points closer to each other? It works fine when I move the point away from the other one and it adjusts itself to the new distance but it doesnt quite work that way when the opposite. In my situation, I use a code based approach so it would be nice to have an at least pseudo-code for that.
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
05-11-2020, 01:09 PM
(This post was last modified: 05-11-2020, 01:13 PM by josemendez.)
(05-11-2020, 01:01 PM)canerozdemir Wrote: I will try and comment the result later on. Thank you. And I forgot to tell, I assign the target but I am not able to assign the end or the start point as a particle group. In the blueprint, those points do exist and I have them on my code. I have "start" and "end" as suggested on the official documentation. But I cant assign them by code so the Obi Particle Attachment doesn't work as expected.
They can be assigned just fine, like you'd do for the target:
Code: attachment.particleGroup = //your group
Can you share the code you're using?
(05-11-2020, 01:01 PM)canerozdemir Wrote: One more question, how can I set the rope length when I move those points closer to each other? It works fine when I move the points away from the other one and it adjusts itself to the new distance but it doesnt quite work that way when the opposite. In my situation, I use a code based approach so it would be nice to have an at least pseudo-code for that.
You can't change rope rest length at runtime by just moving its end points. When you move the point away from each one, you're actually overstretching the rope, but its rest length remains the same. Once the points are closer together than the rope length, it will have some slack. This is just how real world elastic ropes work. The rope's rest length and shape are determined by the blueprint path.
If you let me know more details about your use case, I might be able to help you.
Posts: 17
Threads: 4
Joined: Nov 2020
Reputation:
0
05-11-2020, 01:17 PM
(This post was last modified: 05-11-2020, 01:18 PM by canerozdemir.)
(05-11-2020, 01:09 PM)josemendez Wrote: They can be assigned just fine. Can you share the code you're using?
You can't change rope rest length at runtime by just moving its end points. When you move the point away from each one, you're actually overstretching the rope, but its rest length remains the same. Once the points are closer together than the rope length, it will have some slack. This is just how real world elastic ropes work.
If you let me know more details about your use case, I might be able to help you.
I managed to assign the particle groups. I had to use AppendNewParticleGroup method and I assigned a parameter. It was an oversight on my part.
In my use case, I need the rope to adjust the distance between two points, If the two points are close to each other, the rope needs to be at a length when it doesnt seem that long. Just like the overstretching, I need the rope to have a reverse stretch so it will not be that long when those points are close to each other. Is it possible at all?
Posts: 6,321
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
05-11-2020, 01:23 PM
(This post was last modified: 05-11-2020, 01:26 PM by josemendez.)
(05-11-2020, 01:17 PM)canerozdemir Wrote: I managed to assign the particle groups. I had to use AppendNewParticleGroup method and I assigned a parameter. It was an oversight on my part.
AppendNewParticleGroup will create and append a new group to the blueprint. It shouldn't be necessary to call this, the groups are already present in the blueprint so you just get them.
(05-11-2020, 01:17 PM)canerozdemir Wrote: In my use case, I need the rope to adjust the distance between two points, If the two points are close to each other, the rope needs to be at a length when it doesnt seem that long. Just like the overstretching, I need the rope to have a reverse stretch so it will not be that long when those points are close to each other. Is it possible at all?
If the rope's length is always equal to the distance between to objects, no matter how far apart they're from each other, isn't this just a line? There would be no discernible physics simulation going on at all... I'm afraid there's no built in way to do this, there's no "reverse stretch" equivalent in real world physics, unless you factor in automatic reeling mechanisms or something similar (like the one in a security seatbelt). Still, in this case the rope length is fixed, it just happens to be reeled in by a spring loaded mechanism. You might be able to use the ObiRopeCursor component to do this. See:
http://obi.virtualmethodstudio.com/tutor...ursor.html
Posts: 17
Threads: 4
Joined: Nov 2020
Reputation:
0
(05-11-2020, 01:23 PM)josemendez Wrote: AppendNewParticleGroup will create and append a new group to the blueprint. It shouldn't be necessary to call this, the groups are already present in the blueprint so you just get them.
If the rope's length is always equal to the distance between to objects, no matter how far apart they're from each other, isn't this just a line? There would be no discernible physics simulation going on at all... I'm afraid there's no built in way to do this, there's no "reverse stretch" equivalent in the real world, unless you factor in automatic reeling mechanisms or something similar (like the one in a security seatbelt). Still, in this case the rope length is fixed, it just happens to be reeled in by a mechanism. You might be able to use the ObiRopeCursor component to do this. See:
http://obi.virtualmethodstudio.com/tutor...ursor.html
What I am doing is not realistic anyway so I am making a fun experiment Thank you for your help and support
|