Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Rope centre control
#1
Hello again. In my game there is an ObiRope stretched between two players. It can be lengthened and shortened (I do this thanks to cursor). I'm having trouble taking the centre of the rope and using DOTWEEN to animate moving the centre of the rope (like a hitch) to a certain position, with the characters hanging from both sides. Let me give you an example where you use a stick to lift the rope in the middle of its length. What is the best way to realise this? I created a group of particles and attached it to an empty object with components rigitBody and ObiCollider, but when you resize the rope via cursor this group of particles may disappear and when you increase the rope the attachment.target object appears outside the unity coordinates. In any case I think it is not the best idea to use particlesGroup on a rope dynamically changing its length. Maybe someone can tell me how to realise this feature in a stable way?
I also need the other player not to be suspended and be able to adjust the length of the rope while on one side of the chasm, while the other player can swing while hanging on his half of the rope above the chasm.
Reply
#2
(21-09-2023, 05:48 PM)Alexander34 Wrote: Hello again. In my game there is an ObiRope stretched between two players. It can be lengthened and shortened (I do this thanks to cursor). I'm having trouble taking the centre of the rope and using DOTWEEN to animate moving the centre of the rope (like a hitch) to a certain position, with the characters hanging from both sides. Let me give you an example where you use a stick to lift the rope in the middle of its length. What is the best way to realise this? I created a group of particles and attached it to an empty object with components rigitBody and ObiCollider, but when you resize the rope via cursor this group of particles may disappear and when you increase the rope the attachment.target object appears outside the unity coordinates. In any case I think it is not the best idea to use particlesGroup on a rope dynamically changing its length. Maybe someone can tell me how to realise this feature in a stable way?
I also need the other player not to be suspended and be able to adjust the length of the rope while on one side of the chasm, while the other player can swing while hanging on his half of the rope above the chasm.

Hi,

Depends on the specifics of your use case, but chances are you'll need to deal with individual elements/particles in the rope to find out the center of a dynamically resized rope, and then set its position.

To find the center, pick the element that's it the middle of the rope.elements list. Then pick one of the particles at either end of the center element, and override its position.

let me know if you need further help,

kind regards
Reply
#3
(22-09-2023, 08:55 AM)josemendez Wrote: Hi,

Depends on the specifics of your use case, but chances are you'll need to deal with individual elements/particles in the rope to find out the center of a dynamically resized rope, and then set its position.

To find the center, pick the element that's it the middle of the rope.elements list. Then pick one of the particles at either end of the center element, and override its position.

let me know if you need further help,

kind regards
thanks for the advice on how to find the middle of the rope, now I need to figure out how to move the centre particle steadily without jerks etc.

_obiRope.solver.positions.SetVector3(middleElementIndex, transform.position); works too fast and the particle returns to its position in the very next frame

besides, even if we move this asynchronously and via Vector3.Lerp, when we move this central particle, the other particles in the rope don't reach for it, and I need to exactly grab the centre of the rope and move the players elsewhere.
Reply
#4
(22-09-2023, 03:17 PM)Alexander34 Wrote: thanks for the advice on how to find the middle of the rope, now I need to figure out how to move the centre particle steadily without jerks etc.

_obiRope.solver.positions.SetVector3(middleElementIndex, transform.position); works too fast and the particle returns to its position in the very next frame

besides, even if we move this asynchronously and via Vector3.Lerp, when we move this central particle, the other particles in the rope don't reach for it, and I need to exactly grab the centre of the rope and move the players elsewhere.

Hi,

Again depends on the exact results you’re after, but setting the position of the particle won’t prevent it from going back near its original position as a result of the simulation trying to keep the rope’s length intact.

If you want to completely override the position of a particle so that the simulation can’t affect it, set the particle’s inverse mass to 0, see the description of invMasses array in the manual:

Quote:Inverse mass:
Inverse mass for each particle. An inverse mass of 0 means the particle's mass is infinite, so its position will be unaffected by dynamics (allowing you to override it manually).

This is what static attachments do internally: set the inverse mass to zero to make sure the simulation won’t mess with that particle’s position, then set a custom position value.

Note that when moving a single particle, all other particles in the rope won’t immediately adjust their positions as a result: it will take a few frames of simulation for the rope to react to what is essentially teleporting a part of it. If you want to eg. teleport the entire rope, you must set the position of all its particles.

Kind regards,
Reply