Kassoon

Weekly devlogs - Rogue Legend 2

No idea what this is about? Check out Rogue Legend 2 or Patreon for automatic rewards!
 

September 20 - How Fishing Works

Hello again! There are A LOT of fixes, tweaks, and new survival gameplay in this week. Far too many to cover, so check out the patch notes. I'll do a quick summary: sprains, painkillers, lettuce plant, ice cream, lakes, console commands, wind, clothes, snow, weather, and like a page's worth of bug fixes.

Fishing components

Instead, let's talk fishing, and how it was implemented. Fishing was one of the most complicated tool interactions so far and I ended up breaking it up into 3 components. The rod itself, the fishing bobber, and the fishing line.

Fishing line raycast

I wanted to avoid adding a bunch of new variables to handle fishing since multiple players could fish on the same server at the same time, so I decided to piggyback onto my buffs and debuffs system. When you first use your fishing rod you gain the "cast line" debuff which counts up how long you have the button held down. Once released, it fires a line straight forward from your character based on their facing out to a certain distance based on the range of the rod and how long you held the button down. It then shoots another raycast straight down to find the terrain and checks if the point it hits is a water block. If it is, the debuff expires and you gain the fishing debuff. Why debuffs? Because you can remove buffs by right clicking, and I didn't want you to accidentally remove these.

Bobber bobbing

We then add the fishing bobber to the point the raycast hit, which sits there and floats up and down occasionaly. It's linked to the player so it knows it's yours, and will be automatically cleaned up if anything makes you stop fishing.

Fish search

I added a new behavior to fish that will check for nearby fishing bobbers and go investigate. A nibbling fish causes the bobber to bounce up and down.

Get a fish bite

While fishing you can press the button to pop the bobber back to the surface and reel it in, which causes it to move towards the player and check for valid water spots as it does. If it ever can't find one, you've reeled it in completely. When the bobber is bouncing from a nibbling fish, if you reel it in while it's below the surface of the water, that's a bite and you move to the "reeling it in" debuff.

Curved fishing line

The final component is the fishing line, attached from the rod to the bobber. This uses a simple line render with 3 basic points: The rod, the bobber, and the halfway point. I added a bezier curve script to smooth out the line render and create a nice curve from the rod to the bobber by dropping the halfway point down a bit. To simulate tension on the line while reeling, I turn off the curve when you're reeling in the bobber and add a lerp to Y position of the halfway point to smooth out the movement of the line so it looks like it's actually swaying about.

Caught a fish

So you hooked the fish and need to reel it in, at this point it's relatively simple. I mark the fish as hooked and have it move with the bobber. It also tries to run away, so if you let up on the line it'll bolt and take the bobber with it. If it gets too far away, it gets away so it's a battle of stamina management. I wanted to use the actual fish NPC the whole time with minimal modifications instead of swapping it out for a fishing model, because part of the gameplay is about how everything interacts with each other. So while it's on your line that fish is still interactable. Someone else could come up and spear it to steal it from you, or maybe a bigger fish will want a snack. Anyway, once it's reeled in you've got the fish! I added a little model viewer thing so you can look at your catch, and its length is recorded in your journal.

Now you know how fishing is done. It's one of those things that seems relatively simple and straight-forward but becomes a lot more complicated once it needs to be implemented for a game. See you next week!

Continue Reading in the Dev Forums >>

 

September 13 - How To Fish

Continue Reading in the Dev Forums >>

 

September 6 - Illumination, Globally

Hope you had a good labor day! Between that and last week's late build, this week is mostly fixes. That's austerity for you!

Further tweaks and improvements to lighting outdoors:

New Outdoor Lighting

This will be an ongoing thing most likely, but I like to post pictures frequently to map out the progress. If you're on an older machine and Global Illumination wasn't working for you, it should now, so you too can enjoy improved lighting fidelity.

Fish are now easier to see from the surface of the water. Once you get the fishing rod, you'll be able to spy fish spots from the shore to aim your casts at. I'll talk more about the specifics of fishing once the rod is available.

Continue Reading in the Dev Forums >>

 

< Previous Entries << First Entry  
 

Check out Rogue Legend 2 or Patreon for automatic rewards!

[-]