Posts: 6
Threads: 1
Joined: Jul 2023
Reputation:
0
I'm making a fishing rod mechanic. When I pull the fishing rod to myself, the tip of the fishing rod comes flying.
I draw it to myself by decreasing the stretching scale value in distance constraints.
I want it to come to me slowly and linearly. I don't want it to come flying.
How can i do it?
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
(10-07-2023, 04:58 PM)erenjeagerot Wrote: I'm making a fishing rod mechanic. When I pull the fishing rod to myself, the tip of the fishing rod comes flying.
I draw it to myself by decreasing the stretching scale value in distance constraints.
I want it to come to me slowly and linearly. I don't want it to come flying.
How can i do it?
Hi,
Just reduce the stretching scale slowly over time, that should compress the rope slowly as well. If you have trouble getting this to work, share your code and we'll try to help you with it.
kind regards,
Posts: 6
Threads: 1
Joined: Jul 2023
Reputation:
0
11-07-2023, 12:27 PM
(This post was last modified: 11-07-2023, 12:28 PM by erenjeagerot.)
I read the post below thoroughly and made the adjustments you suggested:
http://obi.virtualmethodstudio.com/forum...ht=fishing
I watched the video you uploaded to youtube. There is no rope pulling in your video.
[url=https://youtu.be/EuPlOZF_zRg][/url]https://youtu.be/EuPlOZF_zRg
When we pull the rope, the rope oscillates a lot to the left and right. This is not something I want. I recorded my test scene on video below.
https://streamable.com/jx8fhe
I do the stretching and pulling of the rope by changing the stretching scale value of the ip under distance constraints.
When I increase the mass value in the rigidbody of the object, it swings back and forth less. But I don't want it to shake at all.
I think it is not possible to do this with obi rope. Because this operation may be against physics.
I can do this with writing code. If you do not have a solution, I will do it with code without using obi rope.
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
11-07-2023, 12:34 PM
(This post was last modified: 11-07-2023, 12:44 PM by josemendez.)
(11-07-2023, 12:27 PM)erenjeagerot Wrote: I watched the video you uploaded to youtube. There is no rope pulling in your video.
When we pull the rope, the rope oscillates a lot to the left and right. This is not something I want. I recorded my test scene on video below.
https://streamable.com/jx8fhe
I have no idea what's going on in your video. Could you post the code you're using for this?
(11-07-2023, 12:27 PM)erenjeagerot Wrote: I do the stretching and pulling of the rope by changing the stretching scale value of the ip under distance constraints.
Decreasing the stretching scale should definitely not result in what's seen in your video, unless you're setting it to extreme values. If should be between 1 (100%) and 0 (0%) in most cases.
(11-07-2023, 12:27 PM)erenjeagerot Wrote: When I increase the mass value in the rigidbody of the object, it swings back and forth less. But I don't want it to shake at all.
I think it is not possible to do this with obi rope. Because this operation may be against physics.
The rope will always behave in a physically driven way: if it's suddenly shortened, it will lash back/curve/jiggle as needed to maintain momentum. You can override this behavior by writing your own velocity/position values in the solver arrays, see the particles API.
This said: if you're going for unphysical behavior, using a full rope simulation for this is probably going to make matters unnecessarily complicated for you. For instance if all you need is to keep a given distance between the end of the fishing rod and the end of the line, a simple distance/spring joint is all you should use.
You can sort of mimic this in Obi by setting the rope blueprint resolution to zero, which will result in a rope with only two particles: one at the start and one at the end. But doing this is kinda like taking an motorcycle and stripping it of the engine, tires, electronics, etc to turn it into a bicycle: it's probably easier to just use a bicycle to start with.
(11-07-2023, 12:27 PM)erenjeagerot Wrote: I can do this with writing code. If you do not have a solution, I will do it with code without using obi rope.
Not sure what you mean by "doing this with writing code", you'll have to write code for this whether you're using Obi or not.
Posts: 6
Threads: 1
Joined: Jul 2023
Reputation:
0
(11-07-2023, 12:34 PM)josemendez Wrote: I have no idea what's going on in your video. Could you post the code you're using for this?
I did not use code. I changed the stretching scale value from the editor.
(11-07-2023, 12:34 PM)josemendez Wrote: Not sure what you mean by "doing this with writing code", you'll have to write code for this whether you're using Obi or not.
What I meant was to do it by writing code without using obi rope.
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
12-07-2023, 04:56 PM
(This post was last modified: 12-07-2023, 05:11 PM by josemendez.)
(12-07-2023, 04:10 PM)erenjeagerot Wrote: I did not use code. I changed the stretching scale value from the editor.
Then of course the rope will spring/wiggle as you change the value! . For instance if the stretching scale is set to 1 and you suddenly change it to 1.2, the rope instantly stretches by 20% which will make it wiggle around. This cannot be avoided unless you change the scale *very* slowly to give the rope time to absorb the momentum (assuming you're changing the scale over time using code) which is what I initially suggested:
Quote:Just reduce the stretching scale slowly over time, that should compress the rope slowly as well.
Stretching scale makes the rope stretch and compress, without actually changing its physical representation. No more rope is added or removed, the existing one is just stretched or compressed like a spring. This means no new particles will be created along the rope, they will simply be spaced apart - if the scale is larger than 1- or brought together - if the scale is smaller than zero. If you add a ObiParticleRenderer to the rope to visualize its particles, you'll clearly see what I mean. This is in no way no equivalent to reeling more rope in/out, which is what a fishing rod does, it's closer to having an elastic rubber band and stretching it.
While setting the stretching scale can be useful in some situations, if you want to actually change the length of the rope you should use a cursor. All included sample scenes that change the length of a rope at runtime (Crane, GrapplingHook, FreightLift just to name some) do it this way.
Let me know if you need further help. Cheers!
Posts: 6
Threads: 1
Joined: Jul 2023
Reputation:
0
I wish the rope length could be adjusted by changing "a variable value" of one of the obi rope components.
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
14-09-2023, 02:48 PM
(This post was last modified: 14-09-2023, 02:53 PM by josemendez.)
(14-09-2023, 02:21 PM)erenjeagerot Wrote: I wish the rope length could be adjusted by changing "a variable value" of one of the obi rope components.
Hi!
Setting the length of a rope doesn't mean anything unless you also specify how the length should be changed (at which point, in which direction) and how the existing rope should react when its length is changed.
Cursors allow you to change the length at runtime, bu specifying a point in the rope where new rope is inserted/removed and in which direction. The rest of the rope will just react physically to the change in length. You can write a component that simply calls cursor.ChangeLength(value), with "value" being exposed in the inspector, this does what you want - but would only work in play mode though.
Since there's no physical simulation outside of play mode, in-editor you can only change rope length by dragging blueprint control points around. This not only allows you to set the length but also the shape of the rope, which is a must.
kind regards,
Posts: 6
Threads: 1
Joined: Jul 2023
Reputation:
0
(14-09-2023, 02:48 PM)josemendez Wrote: Cursors allow you to change the length at runtime, bu specifying a point in the rope where new rope is inserted/removed and in which direction. The rest of the rope will just react physically to the change in length. You can write a component that simply calls cursor.ChangeLength(value), with "value" being exposed in the inspector, this does what you want - but would only work in play mode though.
"cursor.ChangeLength(value)"
Should I open any script and write the command there? Also, what is this thing called "cursor"?
We are not running a function of any obi component here, right?
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
20-09-2023, 06:38 AM
(This post was last modified: 20-09-2023, 06:41 AM by josemendez.)
(19-09-2023, 09:16 PM)erenjeagerot Wrote: Should I open any script and write the command there?
Correct.
(19-09-2023, 09:16 PM)erenjeagerot Wrote: Also, what is this thing called "cursor"?
We are not running a function of any obi component here, right?
As I previously mentioned in this thread, ObiRopeCursor is a Obi component that allows you to change the length of the rope at runtime:
(12-07-2023, 04:56 PM)josemendez Wrote: While setting the stretching scale can be useful in some situations, if you want to actually change the length of the rope you should use a cursor. All included sample scenes that change the length of a rope at runtime (Crane, GrapplingHook, FreightLift just to name some) do it this way.
There's quite a few examples of using cursors in the included sample scenes, and the manual page (there's a link to it in the previous paragraph) also contains sample code.
kind regards,
|