Obi Official Forum
Help Fishing Pole/Line - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Help Fishing Pole/Line (/thread-3406.html)

Pages: 1 2 3


Fishing Pole/Line - Natty - 15-04-2022

Hi All,

Just grabbed Obi Rope and played around with some tutorials and overall got a feel for it.  This tool is amazing.  Definitely worth the purchase, and I will be leaving a review shortly once I get more comfortable with it.

I am trying to implement a fishing pole; to be specific, the fishing line on a fishing pole and casting it out, with the option of reeling it in.  To begin, I'm focusing first on being able to cast it out.  I've created a pole and attached a rope to the pole, and a bobber (just a Unity sphere) to the end of it and added a Rigidbody component to it. My idea is to eventually have an animation play for the player slowly bringing back the rod to then release it forward and cast out.

Currently my fishing system is set up without any animations, but it works by applying a force to the bobber's rigidbody, depending on how long the player holds the button to essentially wind-up a cast.  As it is now, when the player let's go of the cast button the following code is triggered:

Code:
        bobberGO.transform.position = transform.position + yOffset;
        rb.velocity = transform.TransformDirection(10f * fishingCastScrollBarValue * randomPosition);

Which is just setting the bobber at a position of where it would be released, and then applying the physics to the bobber.

Where Obi Rope comes in is that I would like the rope to always start off with a length of where the rope is just hanging from the pole a bit, and then when the player casts out it dynamically resizes until the bobber hits the water.  I currently don't have a system in place to reel in the rope and instead when the player catches a fish or is done fishing, I would just like the rope to be set back to it's original length of hanging from the pole.

Admittedly, I need more time and practice with Obi Rope, but I was hoping someone could point me in the right direction.  I have found resources for ObiRopeCursor, and the tutorials on YouTube, but I'm struggling a bit to get something cohesive working.

Thank you.


RE: Fishing Pole/Line - josemendez - 15-04-2022

(15-04-2022, 12:57 AM)Natty Wrote: Hi All,

Just grabbed Obi Rope and played around with some tutorials and overall got a feel for it.  This tool is amazing.  Definitely worth the purchase, and I will be leaving a review shortly once I get more comfortable with it.

I am trying to implement a fishing pole; to be specific, the fishing line on a fishing pole and casting it out, with the option of reeling it in.  To begin, I'm focusing first on being able to cast it out.  I've created a pole and attached a rope to the pole, and a bobber (just a Unity sphere) to the end of it and added a Rigidbody component to it. My idea is to eventually have an animation play for the player slowly bringing back the rod to then release it forward and cast out.

Currently my fishing system is set up without any animations, but it works by applying a force to the bobber's rigidbody, depending on how long the player holds the button to essentially wind-up a cast.  As it is now, when the player let's go of the cast button the following code is triggered:

Code:
        bobberGO.transform.position = transform.position + yOffset;
        rb.velocity = transform.TransformDirection(10f * fishingCastScrollBarValue * randomPosition);

Which is just setting the bobber at a position of where it would be released, and then applying the physics to the bobber.

Where Obi Rope comes in is that I would like the rope to always start off with a length of where the rope is just hanging from the pole a bit, and then when the player casts out it dynamically resizes until the bobber hits the water.  I currently don't have a system in place to reel in the rope and instead when the player catches a fish or is done fishing, I would just like the rope to be set back to it's original length of hanging from the pole.

Admittedly, I need more time and practice with Obi Rope, but I was hoping someone could point me in the right direction.  I have found resources for ObiRopeCursor, and the tutorials on YouTube, but I'm struggling a bit to get something cohesive working.

Thank you.

Hi!

Calling the ObiRopeCursor’s ChangeLength() method would be the way to go. Initially you want to set it to the length between the tip of the rod and the bobber (might be a fixed distance that you specify) and when the player casts it out, set it to the *measured* (using Vector3.Distance) distance between the tip of the rod and the bobber, plus some extra headroom if you want. That should do it.

Let me know if i can be of further help. Kind regards,


RE: Fishing Pole/Line - Natty - 17-04-2022

(15-04-2022, 09:17 AM)josemendez Wrote: Hi!

Calling the ObiRopeCursor’s ChangeLength() method would be the way to go. Initially you want to set it to the length between the tip of the rod and the bobber (might be a fixed distance that you specify) and when the player casts it out, set it to the *measured* (using Vector3.Distance) distance between the tip of the rod and the bobber, plus some extra headroom if you want. That should do it.

Let me know if i can be of further help. Kind regards,

Hi Jose,

I am making some progress!  

To provide some info in case you have any insights, I am using the default Obi Solver settings.  The rope has 4 control points; one at the pole, one in the middle, then one about a quarter away from the bobber, and then the last one at the very end of rope (pretty similar to what I saw on the Chain example you have).  Obi Rope cursor Cursor Mu is 0.5 and Source Mu is 0.5.  I'm using the included RopeLengthController script.

I'll still need to add a force to the bobber in order for the player to cast it, but that just comes down to Unity/C# that I can whip up.  For now, I'm trying to get the rope settings to be somewhat closer to a fishing line.  The game itself is low poly and I am not trying to create any realistic fishing simulation, just something that looks good and feels fun Sonrisa 

I plan to keep messing with the settings today, but I'm open for any suggestions.

Edit:

Ok so here's an update: https://streamable.com/4yqj8t.  I've added a buoyancy script to the bobber, and the rope no longer snaps now when reeling all the way in.  I am having a hard time keeping the red part of the bobber, floating at the top though, as it seems to get pulled down by the rope?  Not sure how to fix this, but here is the buoyancy script so far: https://hastepaste.com/view/LuX8

Also, the fishing line is way too bouncy, how can I change the elasticity, along with keeping the red tip of the bobber above the water?

Thank you.


RE: Fishing Pole/Line - josemendez - 18-04-2022

(17-04-2022, 06:22 PM)Natty Wrote: I am having a hard time keeping the red part of the bobber, floating at the top though, as it seems to get pulled down by the rope?  Not sure how to fix this, but here is the buoyancy script so far: https://hastepaste.com/view/LuX8

The mass of the rope vs the mass of the bobber will control how they relate to each other, just like in the real world: if the rope mass is high compared to the bobber, it will move/rotate it around easily. Conversely, if the bobber has more mass than the rope, it will move the rope around. (Note you can set the rope's mass on a per-control point basis using the path editor)

You might also want to change the bobber's center of mass (CoM) position. Usually they have a pretty low CoM, if you leave it at its center -which is the default for a sphere- it will easily spin around. See: https://docs.unity3d.com/ScriptReference/Rigidbody-centerOfMass.html

kind regards,


RE: Fishing Pole/Line - Natty - 19-04-2022

(18-04-2022, 09:38 AM)josemendez Wrote: The mass of the rope vs the mass of the bobber will control how they relate to each other, just like in the real world: if the rope mass is high compared to the bobber, it will move/rotate it around easily. Conversely, if the bobber has more mass than the rope, it will move the rope around. (Note you can set the rope's mass on a per-control point basis using the path editor)

You might also want to change the bobber's center of mass (CoM) position. Usually they have a pretty low CoM, if you leave it at its center -which is the default for a sphere- it will easily spin around. See: https://docs.unity3d.com/ScriptReference/Rigidbody-centerOfMass.html

kind regards,
Thanks, Jose.  Unfortunately I've moved some of the control points and now I'm struggling to get the rope to even hang properly.  I'll have to restart and try to understand the point placements a bit more.


RE: Fishing Pole/Line - josemendez - 20-04-2022

(19-04-2022, 02:56 PM)Natty Wrote: Thanks, Jose.  Unfortunately I've moved some of the control points and now I'm struggling to get the rope to even hang properly.  I'll have to restart and try to understand the point placements a bit more.

Hi there!

The rope's path is just a bézier spline, like those you can find in Photoshop, Blender, or many other programs. Control points and tangent handles work in the same way too, shouldn't be too difficult to get the hang of it.

Can I help in any way? Maybe you can share your scene for me to take a look and guide you?


RE: Fishing Pole/Line - Natty - 21-04-2022

(20-04-2022, 08:47 AM)josemendez Wrote: Hi there!

The rope's path is just a bézier spline, like those you can find in Photoshop, Blender, or many other programs. Control points and tangent handles work in the same way too, shouldn't be too difficult to get the hang of it.

Can I help in any way? Maybe you can share your scene for me to take a look and guide you?
Hi Jose,

Thanks, yes looks like I'll need some guidance.  I was hoping I could sort of figure it out, but I don't have much experience with splines.  The rope is again very elastic, and I'm having trouble shortening it (see the drawing I did on the picture with the fishing line).

Ultimately, I am trying to have the fishing line short to begin, as this fishing pole will be equipped to the player's back, so I just want it to hang a little bit and be impacted by some physics while player is walking around.  When fishing, player should be able to cast out by applying physics to the ball and the rope should dynamically expand.

Here's some screenshots from test project.


RE: Fishing Pole/Line - Natty - 26-04-2022

Still messing around with this in my test project (see pics above).  Let me know when you're able to take a look, Jose.  Thanks for all the input and no rush - I see you have been answering everyone that's here!  Appreciate it.


RE: Fishing Pole/Line - josemendez - 27-04-2022

(26-04-2022, 05:44 PM)Natty Wrote: Still messing around with this in my test project (see pics above).  Let me know when you're able to take a look, Jose.  Thanks for all the input and no rush - I see you have been answering everyone that's here!  Appreciate it.

Hi Natty!

Some tips regarding your setup:

- You mention the rope is very elastic, but I see you're using only 1 distance iteration on your solver. Unless you're using many substeps (at least 8) in your updater, there will be a lot of spurious elasticity in your simulation. Crank up the amount of substeps, it's a very important setting in Obi since it's the main quality -vs- performance setting. You can find it in your ObiFixedUpdater component.

The manual contains a very detailed explanation of how the solver works internally and how iterations/substeps (or timestep length in general) affect the quality of the simulation, I'd recommend taking a look:
http://obi.virtualmethodstudio.com/manual/6.3/convergence.html

- Your screenshots don't show the bobber's mass or the rope's mass, but remember that large mass ratios (>= 1:10) will make it difficult for the rope to keep taut. So if your bobber's mass is much larger than the rope's, it will be more elastic than intended.

- Your cursor's parameters are both set to 0.5. This means the cursor will lengthen/shorten the rope by its middle point, by inserting copies of the particle closest to its middle. This is probably not what you want. The cursor should be much closer to the rod's tip. Take a look at the sample "Crane" scene, also see: http://obi.virtualmethodstudio.com/manual/6.3/ropecursor.html

let me know if you need further help,


RE: Fishing Pole/Line - Natty - 29-04-2022

(27-04-2022, 07:56 AM)josemendez Wrote: Hi Natty!

Some tips regarding your setup:

- You mention the rope is very elastic, but I see you're using only 1 distance iteration on your solver. Unless you're using many substeps (at least 8) in your updater, there will be a lot of spurious elasticity in your simulation. Crank up the amount of substeps, it's a very important setting in Obi since it's the main quality -vs- performance setting. You can find it in your ObiFixedUpdater component.

The manual contains a very detailed explanation of how the solver works internally and how iterations/substeps (or timestep length in general) affect the quality of the simulation, I'd recommend taking a look:
http://obi.virtualmethodstudio.com/manual/6.3/convergence.html

- Your screenshots don't show the bobber's mass or the rope's mass, but remember that large mass ratios (>= 1:10) will make it difficult for the rope to keep taut. So if your bobber's mass is much larger than the rope's, it will be more elastic than intended.

- Your cursor's parameters are both set to 0.5. This means the cursor will lengthen/shorten the rope by its middle point, by inserting copies of the particle closest to its middle. This is probably not what you want. The cursor should be much closer to the rod's tip. Take a look at the sample "Crane" scene, also see: http://obi.virtualmethodstudio.com/manual/6.3/ropecursor.html

let me know if you need further help,
Hi Jose,

It's definitely getting better, but still a ways off.  The rope is still fairly elastic; how high should I increase the Distance iterations?  I messed around with it, but wasn't noticing much of a difference beyond ~25. Additionally, how can I start with the rope being a shorter length?  In the starting picture, I would expect the rope to be that long, yet upon pressing play, the rope is MUCH longer.  I am trying to have the rope start at the length, and then be able to increase the length when casting, and reel it back in.

Let me know if you need more details.

As always, thank you!