Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  ObiRope Points
#31
(22-10-2021, 08:04 AM)josemendez Wrote: You can control bending using the rope's bend constraints:
http://obi.virtualmethodstudio.com/manua...aints.html

Increasing compliance will make ropes easier to bend.

Max bending determines the amount of bending at which ropes start to oppose bending. A value of zero means the ropes will always offer resistance to bending (how much resistance is determined by compliance). Higher values will allow the rope to easily bend for a bit, then start resisting bending.


Increase the solver's velocity damping. This will cause particles to lose kinetic energy, make them move slowly as if surrounded by a thick atmosphere. See:
http://obi.virtualmethodstudio.com/manua...olver.html

I see you've set this value to 0.99, that should be more than enough to achieve the behavior seen in the video. If what you're getting is not similar, may you share a video of your current results?

Edit: I saw your videos, I'm assuming the "issue" videos are your current results, and the "right" video is the reference game you're trying to replicate, correct? How are you moving the cubes at the ends of your rope? Looks to me like you're directly setting their transform. This will bypass rope physics entirely, ignoring any forces applied by the rope. This will enable the user to continue pulling the rope even when it's completely tensed up, and make very violent motions that cause tunneling (ropes passing trough each other). As already mentioned before you must use forces to move the cubes at the ends of the rope, and make sure they're attached via dynamic attachments.
i read the values of the mouse and move the objects by changing the position of the transform according to the values of the mouse
Reply
#32
(22-10-2021, 08:20 AM)Matbee Wrote: i read the values of the mouse and move the objects by changing the position of the transform according to the values of the mouse

That's precisely what I've been telling you not to do all the while!  Guiño

Physical objects (both in the real world and game engines) interact trough forces.
A force is basically a mass-weighted acceleration, that is: a change in the object's velocity, dependant on its mass. In Unity, you turn an object into a physical object (with velocity and mass) by adding a rigidbody component.

A transform has no velocity. It is just a position (& rotation & size) in space. So when you do:

object.transform.position = newPosition;

All you're doing is teleporting the object to a new place *instantly*. It will ignore forces of any kind, or any physical objects interacting with it, including ropes.


In Unity, if you directly set the transform of a rigidbody, you will see it does not change its speed and it does not interact with objects around it: it's perfectly possible to simply make a cube teleport to the other side of a solid wall by setting its transform position. Setting the position of the cube will ignore all objects around the cube or any external forces opposing movement.

In this case, you want the cube to be affected by the forces applied by the rope: if the rope is completely tense, you want it to be difficult to move the cube. If the rope is loose, the cube should be easy to move. So you need two forces to act on the cube: one applied by the rope, and one applied by the user. When the rope is not tense, it applies a very small force to the cube: the force applied by the user is larger and allows the cube to move. When the rope is very tense, the force applied by the rope is large and it cancels out the force applied by the user, so the cube does not move any further. Am I making sense?

This is just basic physics, not Obi-specific. It's what happens in the real world, and what all engines (Unity, Obi, Havok, etc) simulate. You would need to do the same if your rope was made using any other engine, for instance a chain of Unity rigidbodies.
Reply
#33
(22-10-2021, 08:30 AM)josemendez Wrote: That's precisely what I've been telling you not to do all the while!  Guiño

Physical objects (both in the real world and game engines) interact trough forces.
A force is basically a mass-weighted acceleration, that is: a change in the object's velocity, dependant on its mass. In Unity, you turn an object into a physical object (with velocity and mass) by adding a rigidbody component.

A transform has no velocity. It is just a position (& rotation & size) in space. So when you do:

object.transform.position = newPosition;

All you're doing is teleporting the object to a new place *instantly*. It will ignore forces of any kind, or any physical objects interacting with it, including ropes.


In Unity, if you directly set the transform of a rigidbody, you will see it does not change its speed and it does not interact with objects around it: it's perfectly possible to simply make a cube teleport to the other side of a solid wall by setting its transform position. Setting the position of the cube will ignore all objects around the cube or any external forces opposing movement.

In this case, you want the cube to be affected by the forces applied by the rope: if the rope is completely tense, you want it to be difficult to move the cube. If the rope is loose, the cube should be easy to move. So you need two forces to act on the cube: one applied by the rope, and one applied by the user. When the rope is not tense, it applies a very small force to the cube: the force applied by the user is larger and allows the cube to move. When the rope is very tense, the force applied by the rope is large and it cancels out the force applied by the user, so the cube does not move any further.

This is just basic physics, not Obi-specific. It's what happens in the real world, and what all engines (Unity, Obi, Havok, etc) simulate. You would need to do the same if your rope was made using any other engine, for instance a chain of Unity rigidbodies.
Let's say I want to move my fork to a higher position, now I am doing it like this. How am I supposed to do this using physics?

_plugObject.transform.position = new Vector3(_plugObjectPos.x, _plugObjectPos.y + 0.5f, _plugObjectPos.z);

or

_currentPosition = GetMousePosition();
var deltaX = _currentPosition.x - _prevPosition.x;
_plugObject.transform.position = new Vector3(_plugObject.transform.position.x + deltaX, _plugObject.transform.position.y, _plugObject.transform.position.z);
Reply
#34
To give you step-by-step directions:

1) Add a Rigidbody component to your cube. This will endow the cube with mass and velocity (both linear and rotational).
2) Attach the rope to the cube using a dynamic attachment. This will allow the rope to apply forces to the cube.
3) Use rigidbody.AddForce() to allow the user to move the cube.

That's it! you can play with the cube and the rope's mass to make it easier or harder to move the cube around. If the cube has more mass than the rope, it will be easier to move the cube and pull the rope. If the rope has more mass, moving the cube will be harder and you won't be able to tense the rope a lot.
Reply
#35
(22-10-2021, 08:41 AM)Matbee Wrote: Let's say I want to move my fork to a higher position, now I am doing it like this. How am I supposed to do this using physics?

_plugObject.transform.position = new Vector3(_plugObjectPos.x, _plugObjectPos.y + 0.5f, _plugObjectPos.z);

or

_currentPosition = GetMousePosition();
var deltaX = _currentPosition.x - _prevPosition.x;
_plugObject.transform.position = new Vector3(_plugObject.transform.position.x + deltaX, _plugObject.transform.position.y, _plugObject.transform.position.z);

Using rigidbody.AddForce. See:
https://docs.unity3d.com/ScriptReference...Force.html

Edit: this tutorial will be useful to you: it's for 2D rigidbodies, but the same applies to 3D:
https://www.studytonight.com/game-develo...ay-to-move

I'd recommend reading up on physics and how to move objects in Unity. Obi is a quite advanced engine, it will be very confusing and difficult to use if you're not familiar with the basics first.
Reply
#36
(22-10-2021, 08:46 AM)josemendez Wrote: Using rigidbody.AddForce. See:
https://docs.unity3d.com/ScriptReference...Force.html

Edit: this tutorial will be useful to you: it's for 2D rigidbodies, but the same applies to 3D:
https://www.studytonight.com/game-develo...ay-to-move

I'd recommend reading up on physics and how to move objects in Unity. Obi is a quite advanced engine, it will be very confusing and difficult to use if you're not familiar with the basics first.
Thank you, I will redo it for physics. What parameter should I adjust so that my rope does not bend so much? I want her to be much more equal and not bend


.png   rope.PNG (Size: 26.87 KB / Downloads: 14)
Reply
#37
(22-10-2021, 12:40 PM)Matbee Wrote: Thank you, I will redo it for physics. What parameter should I adjust so that my rope does not bend so much? I want her to be much more equal and not bend

Quoting my previous post:

"You can control bending using the rope's bend constraints:
http://obi.virtualmethodstudio.com/manua...aints.html

Increasing compliance will make ropes easier to bend.

Max bending determines the amount of bending at which ropes start to oppose bending. A value of zero means the ropes will always offer resistance to bending (how much resistance is determined by compliance). Higher values will allow the rope to easily bend for a bit, then start resisting bending."

Spending more iterations in bend constraints will allow the engine to reach higher bending stiffness. So:

- Set the rope's bend compliance to zero.
- Set the rope's max bending to zero.
- Increase the amount of bend constrain iterations in the solver.
Reply