Hey guys, I’m making a first person survival game and I’m currently working on the underwater/swimming aspect of it. I’ve created a standard physics water volume for the water.
For underwater movement, I want the player to be able to control how deep underwater they are (the z value) by looking up or down (think minecraft/ark)
I figured that the best way to do this would be to cast a line a few units in front of the camera wherever the player is looking, check if it’s less/more than the character’s current position, and move the z value up or down accordingly.
The line trace does work, but unfortunately, I’ve run into some pretty big issues, and I’m not too sure how to fix them, as I’m very inexperienced with movement related stuff.
My first issue is that my line trace function is constantly looping even when I’m not pressing anything. This is weird to me because I’m just using the default movement input that came with my characterBP.
The second issue is tied into the first one I think. I can control the z value of my character by aiming higher or lower, but the movement keys don’t do anything. I just aim my mouse around without pressing anything, and it moves my character. In fact, my movement keys don’t appear to work at all.
The third issue is that my character’s x and y coordinates are moving too, even though my function is only using the z value of the raycast, and the y and x are the exact same as far as I know. The character gets pulled backwards when I aim my mouse down, and forwards slightly when I aim up.
To conclude, I have no idea what I’m doing here, I would appreciate any help haha.