3-22 A final push

 So, did those changes from the last post work? No, but hopefully we can get that to change. For starters, I need to find out what the speed is reading. 

This print string node I found will show it on the screen, and it's showing as (0,0,0), which tells me the blueprint is not looking at the right thing. Or, maybe it is? I'm not sure exactly, and after testing some of the other nodes and doing a little research, I landed on this thread from the unreal forums:

https://forums.unrealengine.com/t/how-to-i-get-motion-controllers-velocity/97140

and I decided to test the world position of the controllers, which did show up and update so, trying that looks like this:


and surprisingly, it works sort of. It outputs around 2 in the Z when I do the reeling motion, so that should be what I need to use when looking for that. The next step was to hook that up to the temporary delete which looks like this: 

With the AND node looking at the collision. Now it is time to test this, and...

Instant Fish Delete. Looking at what might have gone wrong, turns out I set the speed to the velocity instead of the base value. So when it collides, It was greater or equal to itself and just deleted, but now after fixing it the blueprint looks like this:



and in-game looks like this: 




It works! So now using this same logic, we can track and use two things:

1. The position of the fish to make it move back to the player when you reel

2. The position of the rod to yank the fish in. 

Starting with the fish:
 
My first thought was to try something like this


With the player location as the target, and the current location looking at the fish, interpolating the two values should allow the fish to move to the player rather than teleport. As well, the interp speed also can be plugged into the velocity we calculated so that in theory, faster hand movement = faster speed moving to the player. 

When testing it, however, it didn't work. I figured it has something to do with the way the level blueprint was set up, so I made a few adjustments to it. It ended up like this:

I thought that by changing how the movement worked and looking at the bools from the bobber in the level blueprint itself, I could either move the fish to the player or move the fish to its original position based on those bools. 
Upon booting into the game, however, this would move the fish to the bobber, then when hooked, it would stop. Turns out, I had the flow wrong, and it was moving before it checked any of the variables. After some slight flow adjustments, here's the level blueprint:

And in-game, it moves to a point, stops when you hook it, and then moves to the player if the velocity is ever over the reeling threshold. 
My next attempt got a little messy, but it was closer in function to the end goal. 

This uses VInterp to and the velocity from the bobber's script to control the speed at which things move around. I did a test where I forgot to set the interp speeds, but it just teleported around. I have a little adjusting those speeds and tick rates but let's look at yanking the fish in. 

For starters, here's the copy and paste from the reeling speed looking at the speed from the rod:


Now we need to look at the position of the fish versus the position of the player. Here's my first pass at that:

This looks at the position of the bobber and the player, subtracts values, and if the two horizontal axes are less than 3 apart, and the player yanks the rod, the fish gets deleted.

Neither of the two worked, but the solution was not easy. After playing with it for a while, here's the level blueprint:



It took a lot of messing with the numbers of how far away the fish should be, how hard you actually have to yank the rod, etc., but the main part was the inclusion of the Absolute value functions, that way it makes it more consistent with the greater or less than operations. I also had to switch the Destroy Component to Destroy Actor. I'm not sure if that has to do with being the level blueprint or if it's something else, but I tested it and it works so. 

Here's a video of the mechanics working in action:

As you can see, the fish now starts to move towards the bobber, once hooked, it moves away and moves closer based on how fast you are reeling. Then if you yank the rod when it is close enough, the fish is "caught" or in this case deleted from the pond. 

Comments