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.
When using nodes like Add Controller Input or Add Movement Input, a lot of what’s actually driving the movement of the character and camera isn’t actually taking place on the pawn or camera itself, but rather being piped in from the player controller or character movement component, which can make things not behave like you think they should.
Anyway, you don’t need any of this stuff. You can return your character blueprint to the default setup, and then go into the class defaults and enable “Use Controller Rotation Pitch”.
Do you mean Use Controller Desired Rotation in the CharacterMovement defaults? I don’t see any Use Controller Rotation Pitch. Also, I enabled it and removed the function I made earlier and it’s not really doing anything at all different than the default movement function.
If anyone else has an answer please feel free to input
No, it’s not the CharacterMovement defaults, that’s the CharacterMovement component. You want the class defaults for the entire blueprint. At the top of the blueprint to the left of the play button, there is a button called “Class Defaults”. In there select “Use Controller Rotation Pitch” under “Pawn” in the details panel.
Ok. I enabled that but it still isn’t really doing much. Are you sure theres not something else I need to add?
I’m pretty sure, I just tried it with the default first person template. Try creating a new project and try it there. Also make sure your volume has “Water Volume” selected. Use Controller Rotation Pitch will only work in the water volume.
You’re right, it does work in the first person template. Could it be because I based my actual game project off of the third person template?
Wait, as in the character blueprint itself is based on the ThirdPersonCharacter BP, or you created a new First Person BP in the Third Person Template project?
It’s based on the thirdpersoncharacter. I wanted to do this because it’s going to be multiplayer and I would need a thirdperson mesh for other players to view.
I’m not super familiar with networking, but I don’t think that’s how you would set that up. I think it would be more like a different mesh component is being replicated in the First Person BP, that the owning player can’t see.
Anyway, yes, the ThirdPersonCharacterBP has a completely different setup by default in the movement and camera components. I’m not sure how to fix that without looking at it for awhile.