Posts: 30
Threads: 9
Joined: Jul 2023
Reputation:
0
Greetings again. I have once again encountered a problem. The thing is that my ObiRope has two states. There are two players and there is a rope between them (like in Unravel), the rope becomes material only when both players grab it. The thing is that when I disable ObiRope and turn off collisions, so that it continues its life cycle, but visually it is not visible. I do this so that when I turn on ObiRope rendering, the rope does not make jerks and jumps when changing its length through Cursor. However, I think that I don't need its life cycle in the off state at all. But there is a problem. Players move all the time, and ObiRope.restLentght should always be = Vector3.Distance(player1.transform.position, player2.transform.position). I change its length via cursor and everything would be fine, but - when I turn on the rope rendering and set cursor.ChangeLength(Vector3.Distance(player1.transform.position, player2.transform.position)) there are constantly jerks. I increase and decrease the number of sub-steps in distance and in solver, but it either heavily loads the hardware or behaves very unstable. Please advise me, how do I turn on the rope, set its length in 1 frame between players, and so that it does not jerk and do not attract players jerks, at the same time you should take into account that when you completely disable ObiRope, ObiRopeAttachment also do not follow the players and when you turn on there is a strong jump rope.
How can I calm the rope, setting it evenly stretched between players always, despite the distance between them, limiting it only to increase in length when the characters are separated from each other and shortening if they come together and be able to turn it off and on without jerks and jerks.
Posts: 6,347
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
29-09-2023, 11:56 AM
(This post was last modified: 29-09-2023, 12:02 PM by josemendez.)
Hi,
(29-09-2023, 11:38 AM)Alexander34 Wrote: The thing is that when I disable ObiRope and turn off collisions, so that it continues its life cycle, but visually it is not visible.
Disabling the ObiRope component won't make it continue its life cycle, it disables it entirely. When you re-enable the rope, it will be re-enabled and its state copied from the blueprint data.
To keep the rope from rendering but otherwise keep simulating, disable its ObiRopeExtrudedRenderer instead (or whichever renderer you're using).
(29-09-2023, 11:38 AM)Alexander34 Wrote: But there is a problem. Players move all the time, and ObiRope.restLentght should always be = Vector3.Distance(player1.transform.position, player2.transform.position). I change its length via cursor and everything would be fine, but - when I turn on the rope rendering and set cursor.ChangeLength(Vector3.Distance(player1.transform.position, player2.transform.position)) there are constantly jerks.
This is because changing the length of a rope does not actually change its shape (that is, it does not move particles around) - it only changes its length by adding or removing particles from the pool and placing them at the cursor's "source mu" position. Otherwise, the rope keeps its current shape. If you need the rope particles to be placed at a specific place (for instance in a straight line that joins both players), you need to do this yourself using the particles API.
See for instance the RopeGrapplingHook sample scene: when initially extending the hook, it does so in a straight line. This is accomplished by setting particle inverse masses to zero (to temporarily make them kinematic) and explicitly setting each particle's position.
Quote:I increase and decrease the number of sub-steps in distance and in solver, but it either heavily loads the hardware or behaves very unstable.
This will only increase simulation accuracy (and negatively affect performance), but won't fix the flawed logic in your approach.
(29-09-2023, 11:38 AM)Alexander34 Wrote: at the same time you should take into account that when you completely disable ObiRope, ObiRopeAttachment also do not follow the players and when you turn on there is a strong jump rope.
If the rope is disabled, attachments won't work because there's no rope to attach. When re-enabling the rope, particles will be re-attached causing the rope to jump. Again, the solution to this is to explicitly set particle positions.
kind regards,
Posts: 30
Threads: 9
Joined: Jul 2023
Reputation:
0
(29-09-2023, 11:56 AM)josemendez Wrote: Hi,
Disabling the ObiRope component won't make it continue its life cycle, it disables it entirely. When you re-enable the rope, it will be re-enabled and its state copied from the blueprint data.
To keep the rope from rendering but otherwise keep simulating, disable its ObiRopeExtrudedRenderer instead (or whichever renderer you're using).
This is because changing the length of a rope does not actually change its shape (that is, it does not move particles around) - it only changes its length by adding or removing particles from the pool and placing them at the cursor's "source mu" position. Otherwise, the rope keeps its current shape. If you need the rope particles to be placed at a specific place (for instance in a straight line that joins both players), you need to do this yourself using the particles API.
See for instance the RopeGrapplingHook sample scene: when initially extending the hook, it does so in a straight line. This is accomplished by setting particle inverse masses to zero (to temporarily make them kinematic) and explicitly setting each particle's position.
This will only increase simulation accuracy (and negatively affect performance), but won't fix the flawed logic in your approach.
If the rope is disabled, attachments won't work because there's no rope to attach. When re-enabling the rope, particles will be re-attached causing the rope to jump. Again, the solution to this is to explicitly set particle positions.
kind regards, Thanks for the detailed answer, yes absolutely, I don't disable ObiRope, I disable its Renderer, I apologize for the wrong translation. If I explicitly set the positions of the particles and disable their mass, making them kinematic, I will not be able to switch the lever with this rope (which is necessary in my game). It won't react to the rest of the ObiCollider, or it will react as a kinematic object, which is not exactly what I need. I need to keep the rope taut between the players, but if the players run in different directions, it should stay taut and not increase. This way we can grab the rope, and in a taut state move physical objects with it, hang on it, etc., which is unlikely to be achieved by explicitly setting the positions of particles and disabling their mass. On the other hand I could do it to just stabilize it before turning it on, I understand that this is the most stable and correct way?
Posts: 6,347
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
29-09-2023, 12:57 PM
(This post was last modified: 29-09-2023, 01:04 PM by josemendez.)
(29-09-2023, 12:38 PM)Alexander34 Wrote: Thanks for the detailed answer, yes absolutely, I don't disable ObiRope, I disable its Renderer, I apologize for the wrong translation. If I explicitly set the positions of the particles and disable their mass, making them kinematic, I will not be able to switch the lever with this rope (which is necessary in my game). It won't react to the rest of the ObiCollider, or it will react as a kinematic object, which is not exactly what I need. I need to keep the rope taut between the players, but if the players run in different directions, it should stay taut and not increase. This way we can grab the rope, and in a taut state move physical objects with it, hang on it, etc., which is unlikely to be achieved by explicitly setting the positions of particles and disabling their mass. On the other hand I could do it to just stabilize it before turning it on, I understand that this is the most stable and correct way?
Setting the mass and position of particles is only done once, when initially activating the rope between players, just like in the grappling rope example where positions are only overriden while the grapple is extending towards its attachment point.
Once your rope has been properly positioned, just set the masses back to their original value to resume the dynamic simulation.
|