Disable camera movement when crouching

When you use Crouch function in Unreal, it changes half height of capsule component and thus camera adjusts. However, I would like to adjust capsule height but not move camera. If I dont change half height for capsule component on player I get what I want but I can’t crouch under objects as my capsule is still same height. Im doing a 2.5D Sidescroller and this is slightly annoying. What are my options?

May I see your Components tab?

I’m not entirely sure what’s wrong and it’s hard to find what exactly you did do wrong without knowing your setup.

Just a small picture of tab on side with root, mesh and so on. :slight_smile:

Here you go:

Ah I just meant one picture of little components tab on left but more better :smiley:

Anyway sorry that I can’t provide a solution right away but I’m only on my laptop right now and won’t get back on Unreal till tomorrow. If there’s no solution by then I’ll come back to it and search for a fix :slight_smile:

I’m not exactly sure how your setup is done, but I would do something along these lines:

Get height change of camera component when you crouch and just set camera location to location + height change. This should keep z value same as it was before.

In other words, set Z value of relative location of camera component when you crouch to add Z to it so it doesn’t move.

Thats what I have tried, however going from In Air to crouch makes camera shake a bit which Im trying to fix.

Your best option is going to be creating your own custom crouch function, as pre-made function is going to move camera by default. You can take a look at this post for an idea of how to set that up:

Hope that helps!

I found a dirty fix you could say. I attached camera to mesh instead of root component and worked like a beaut, it would only move by 1 up or down Z axis so I just told camera to move up 1 or down 1 depending on crouching or not. I did same method with Root component but its a bigger difference and there is some shakyness.

Tl;DR Attached camera to mesh, all good.

1 Like