Posts: 5
Threads: 1
Joined: May 2021
Reputation:
0
I have a rope attached at two points, when disabling the rope component or its game object and then re-enabling it, one of the attachments bugs out and is offset by a few meters. How can fix this? Whats the proper way of disabling and then re-enabling a rope?
Thanks
Posts: 6,323
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
07-05-2021, 08:07 AM
(This post was last modified: 07-05-2021, 08:39 AM by josemendez.)
(07-05-2021, 07:57 AM)headcoach Wrote: I have a rope attached at two points, when disabling the rope component or its game object and then re-enabling it, one of the attachments bugs out and is offset by a few meters. How can fix this? Whats the proper way of disabling and then re-enabling a rope?
Thanks
Hi there,
I'm unable to reproduce this so far. Disabling and re-enabling a rope should should not alter attachment behavior at all.
What Unity version are you using?
What Obi version are you using?
Which backend? (Oni or Burst)?
What kind of attachments? (static or dynamic)?
Note: Attachments will attach the particle to the target at whatever position the particle is in (relative to the target) when they're enabled. This is done to prevent overstretching and sudden jumps in simulation.
This also means that, if you're using a dynamic attachment to attach to a rigidbody and you only disable the rope, the rigidbody will fall (no longer supported by the rope) and when re-enabling the attachment, it will be attached in a different position. In these cases you generally want to disable both the rigidbody and the rope together, or manually set the particle positions before re-enabling the rope.
Posts: 5
Threads: 1
Joined: May 2021
Reputation:
0
https://www.youtube.com/watch?v=oDRN8YkgYuU
Heres a video of the issue, I'm using Unity 2020.3.7 and the latest version of Obi rope, using burst for backend and static attachments, Although I did try with dynamic attachment and got the same result.
Posts: 6,323
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
07-05-2021, 11:14 AM
(This post was last modified: 07-05-2021, 12:07 PM by josemendez.)
(07-05-2021, 11:02 AM)headcoach Wrote: https://www.youtube.com/watch?v=oDRN8YkgYuU
Heres a video of the issue, I'm using Unity 2020.3.7 and the latest version of Obi rope, using burst for backend and static attachments, Although I did try with dynamic attachment and got the same result.
Hi,
I'm unable to reproduce this, and have had no other reports of anything similar. When disabling/renabling the rope, attachments stay at their original positions for me:
Have tried both Burst and Oni backends, on Unity 2019.3.1 and 2020.2.0.
Could you send a scene that reproduces this to support(at)virtualmethodstudio.com so that i can take a look?
thanks!
Posts: 5
Threads: 1
Joined: May 2021
Reputation:
0
07-05-2021, 12:19 PM
(This post was last modified: 07-05-2021, 12:24 PM by headcoach.)
I figured out the cause, changing the ropes length at all using ObiRopeCusor.ChangeLength() and then disabling the rope and then re-enabling the rope is the cause. Will try and put a simple scene together
Edit: If use the sample scene "Crane" that comes with ObiRope and change the load to a static attachment and remove the rigidbodies you can replicate this, by simply changing the rope length with w or s and disabling the rope and re-enabling it
Posts: 6,323
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
07-05-2021, 12:29 PM
(This post was last modified: 07-05-2021, 12:31 PM by josemendez.)
(07-05-2021, 12:19 PM)headcoach Wrote: I figured out the cause, changing the ropes length at all using ObiRopeCusor.ChangeLength() and then disabling the rope and then re-enabling the rope is the cause. Will try and put a simple scene together
When you change the length of a rope using a cursor, the rope is temporarily changed: particles are added/removed, and constraints are reordered for efficient parallelization. Same happens when you cut a rope.
If you disable and then re-enable the rope, it will go back to its original length (and reset any cuts/torn parts). This is the intended behavior, as resizing and tearing rope are operations that do not permanently alter the rope's blueprint.
May I ask what's your use case?
Posts: 5
Threads: 1
Joined: May 2021
Reputation:
0
(07-05-2021, 12:29 PM)josemendez Wrote: When you change the length of a rope using a cursor, the rope is temporarily changed: particles are added/removed, and constraints are reordered for efficient parallelization. Same happens when you cut a rope.
If you disable and then re-enable the rope, it will go back to its original length (and reset any cuts/torn parts). This is the intended behavior, as resizing and tearing rope are operations that do not permanently alter the rope's blueprint.
May I ask what's your use case?
I'm using the rope to visualize controls on sailing boat, I'm just increasing the rope length when the sails are allowed to move further out, so it makes it look like the player is actually controlling the sail with the rope but its only visual. The reason disabled/enabled is the game is multiplayer and the boat needs to be networked, I'm using spatial hashing to disable networked objects that are far away from the player, I could just make the boats ignore spatial hashing but that doesn't seem ideal. Is there a way of setting the rope back to its default values before enabling it again so it attaches properly? Because then I could just do that then set the rope length back to where I want it.
Just also wanna say thank you for the help so far! I really appreciate it
Posts: 6,323
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(07-05-2021, 01:03 PM)headcoach Wrote: I'm using the rope to visualize controls on sailing boat, I'm just increasing the rope length when the sails are allowed to move further out, so it makes it look like the player is actually controlling the sail with the rope but its only visual. The reason disabled/enabled is the game is multiplayer and the boat needs to be networked, I'm using spatial hashing to disable networked objects that are far away from the player, I could just make the boats ignore spatial hashing but that doesn't seem ideal. Is there a way of setting the rope back to its default values before enabling it again so it attaches properly? Because then I could just do that then set the rope length back to where I want it.
Just also wanna say thank you for the help so far! I really appreciate it
In that case, you need to store the rope's current state somewhere. That can be done by either storing particles and current constraint configuration when the boat is disabled, so that it can be restored when the boat is enabled again (this can be a bit complicated) or simply by storing the intended length and calling ChangeLength(storedLength) right after enabling the boat.
(07-05-2021, 01:03 PM)headcoach Wrote: Just also wanna say thank you for the help so far! I really appreciate it
You're welcome . Let me know if you need further help.
Posts: 5
Threads: 1
Joined: May 2021
Reputation:
0
Figured out what I needed, ObiRope.ResetParticles() needs to be called before the rope is disabled so that the attachment will behave properly when re-enabled.
Posts: 6,323
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
07-05-2021, 01:47 PM
(This post was last modified: 07-05-2021, 01:47 PM by josemendez.)
(07-05-2021, 01:45 PM)headcoach Wrote: Figured out what I needed, ObiRope.ResetParticles() needs to be called before the rope is disabled so that the attachment will behave properly when re-enabled.
That will make sure the attachment stays in place (as it resets particles to their original positions, prior to changing length) but won't keep the same rope length after enabling. It will be stretched when re-enabled, might not look bad (as stretching does not cause instabilities in Obi) but I'm almost sure it's not what you want.
|