C++ Crouching Mesh Moves

Hello all ive recently been attempting to implement a crouch function for the my game. Ive tried implementing it the way the survival c++ series does it but when i do for some reason when i crouch my character skeletal mesh move upwards but the camera moves as it should. Even when i uncrouch the mesh then proceeds to stay in its new position. any ideas?

Camera Manager:

/* Apply smooth camera lerp between crouch toggling */
	if (MyPawn)
		if (MyPawn->bIsCrouched && !bWasCrouched)
			CurrentCrouchOffset = MaxCrouchOffsetZ;
		else if (!MyPawn->bIsCrouched && bWasCrouched)
			CurrentCrouchOffset = -MaxCrouchOffsetZ;

		bWasCrouched = MyPawn->bIsCrouched;
		/* Clamp the lerp to 0-1.0 range and interpolate to our new crouch offset */
		CurrentCrouchOffset = FMath::Lerp(CurrentCrouchOffset, 0.0f, FMath::Clamp(CrouchLerpVelocity * DeltaTime, 0.0f, 1.0f));

		FVector CurrentCameraOffset = MyPawn->springArm->GetRelativeTransform().GetLocation();
		FVector NewCameraOffset = FVector(CurrentCameraOffset.X, CurrentCameraOffset.Y, DefaultCameraOffsetZ + CurrentCrouchOffset);
		MyPawn->springArm->TargetOffset = NewCameraOffset;


void ABattleCharacter::OnCrouchToggle()
	if (IsSprinting())

	// If we are crouching then CanCrouch will return false. If we cannot crouch then calling Crouch() wont do anything
	if (CanCrouch())

Before Crouch:
Screenshot (56).png

After Crouch:
Screenshot (55).png


what exactly happens OnCrouch()?

What happens when you redo Crouch/UnCrouch several times? Does it “fly” higher?

Shouldnt there be any kind of Crouching Animation?

Does the log states something suspicious?
Maybe it fires an undesired collision which is not handled?


Hey thanks for the responce :slight_smile: it means alot. if your reffering to the Crouch() and UnCrouch() Methods then they are declared in the ACharacter() class which is default in unreal. To my knowledge it changes the bWantsToCrouch boolean to true or false.
If i continously press the crouch button the mesh stays still but the camera moves as it should.
And there is no animation at the moment it is litrualy just a skeletal mesh.
The log states nothing sadly :frowning:

OMG im so stupid xD turns out my issue is that crouch uses the default location of my mesh however i overwritten these when i place my character in the level so i then made those values default and it works as it should. thank your for your help and sorry for wasteing your time :stuck_out_tongue:

Theres a checkbox on the character for when crouched if the base of the capsule maintains its position or not. I wonder if that’s part of it? Its probably because you have your components parented a bit strangely. Crouch definitely works, I recently setup a crouching character with no problems in 4.12.3