Problem packaging custom movement component

Hi, I am trying to package a version of a game but have some problems during packaging

[7/8] Link [x64] FPS.exe
   Creating library *:\*\FPS\Binaries\Win64\FPS.lib and object *:\*\Blaster\Binaries\Win64\Blaster.exp
MultiplayerMovementComponent.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual class FNetworkPredictionData_Client * __cdecl UMultiplayerMovementComponent::GetPredictionData_Client(void)const " (?GetPredictionData_Client@UMultiplayerMovementComponent@@UEBAPEAVFNetworkPredictionData_Client@@XZ)
MultiplayerMovementComponent.gen.cpp.obj : error LNK2001: unresolved external symbol "protecte*: virtual void __cdecl UMultiplayerMovementComponent::UpdateFromCompressedFlags(unsigned char)" (?UpdateFromCompressedFlags@UMultiplayerMovementComponent@@MEAAXE@Z)
MultiplayerMovementComponent.gen.cpp.obj : error LNK2001: unresolved external symbol "protecte*: virtual void __cdecl UMultiplayerMovementComponent::OnMovementUpdated(float,struct UE::Math::TVector<double> const &,struct UE::Math::TVector<double> const &)" (?OnMovementUpdated@UMultiplayerMovementComponent@@MEAAXMAEBU?$TVector@N@Math@UE@@0@Z)
CharacterAnimInstance.cpp.obj : error LNK2019: unresolved external symbol "public: bool __cdecl UMultiplayerMovementComponent::IsSprinting(void)" (?IsSprinting@UMultiplayerMovementComponent@@QEAA_NXZ) referenced in function "private: virtual void __cdecl UCharacterAnimInstance::NativeThreadSafeUpdateAnimation(float)" (?NativeThreadSafeUpdateAnimation@UCharacterAnimInstance@@EEAAXM@Z)
BaseCharacter.cpp.obj : error LNK2001: unresolved external symbol "public: bool __cdecl UMultiplayerMovementComponent::IsSprinting(void)" (?IsSprinting@UMultiplayerMovementComponent@@QEAA_NXZ)
BaseCharacter.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl UMultiplayerMovementComponent::Sprint(void)" (?Sprint@UMultiplayerMovementComponent@@QEAAXXZ) referenced in function "public: void __cdecl ABaseCharacter::Sprint(void)" (?Sprint@ABaseCharacter@@QEAAXXZ)
BaseCharacter.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl UMultiplayerMovementComponent::StopSprinting(void)" (?StopSprinting@UMultiplayerMovementComponent@@QEAAXXZ) referenced in function "protecte*: void __cdecl ABaseCharacter::AimButtonPressed(void)" (?AimButtonPressed@ABaseCharacter@@IEAAXXZ)
BaseCharacter.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl UMultiplayerMovementComponent::Aim(void)" (?Aim@UMultiplayerMovementComponent@@QEAAXXZ) referenced in function "protecte*: void __cdecl ABaseCharacter::AimButtonPressed(void)" (?AimButtonPressed@ABaseCharacter@@IEAAXXZ)
BaseCharacter.cpp.obj : error LNK2019: unresolved external symbol "public: void __cdecl UMultiplayerMovementComponent::StopAim(void)" (?StopAim@UMultiplayerMovementComponent@@QEAAXXZ) referenced in function "protecte*: void __cdecl ABaseCharacter::AimButtonReleased(void)" (?AimButtonReleased@ABaseCharacter@@IEAAXXZ)
*:\*\Blaster\Binaries\Win64\FPS.exe : fatal error LNK1120: 8 unresolved externals
[8/8] WriteMetadata FPS.target cancelled
CompilationResultException: Error: OtherCompilationError
   at UnrealBuildTool.ActionGraph.ExecuteActions(BuildConfiguration BuildConfiguration, List`1 ActionsToExecute, List`1 TargetDescriptors, ILogger Logger) in *:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\System\ActionGraph.cs:line 399
   at UnrealBuildTool.BuildMode.Build(TargetMakefile[] Makefiles, List`1 TargetDescriptors, BuildConfiguration BuildConfiguration, BuildOptions Options, FileReference WriteOutdatedActionsFile, ILogger Logger) in *:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 753
   at UnrealBuildTool.BuildMode.Execute(CommandLineArguments Arguments, ILogger Logger) in *:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\Modes\BuildMode.cs:line 248
   at UnrealBuildTool.UnrealBuildTool.Main(String[] ArgumentsArray) in *:\build\++UE5\Sync\Engine\Saved\CsTools\Engine\Source\Programs\UnrealBuildTool\UnrealBuildTool.cs:line 599
WriteFileIfChanged() wrote 0 changed files of 36 requested writes.
Timeline:

[ 0.000]
[ 0.000](+16.132) <unknown>
[16.132]

I already checked all the includes on the files and the modules on the *.build.cs file

PublicIncludePaths.AddRange(new string[] { "FPS" });
	PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });

Does MultiplayerMovementComponent have
#include "GameFramework/CharacterMovementComponent.h"
in it’s cpp file or in it’s header?

your functions

-Sprint
-StopSprinting
-Aim
-StopAim
seem to be throwing errors.

I’m guessing they are of type server & maybe withValidation
remember they need

  • the _Implementation version
  • the _Validate version of type return bool if withValidation is in the function macro.
    in the cpp

Also be sure to not copy paste override on a header definition if it doesn’t override anything in the parent.

Strange that it would throw errors during packing and not in the compile process. They don’t seem like runtime errors.

Could you post the header definition and cpp implementation of these commands (you can ommit internals I’m just curious of the function definitions in h & cpp)

Yes, my UMultiplayerMovementComponent contains the include because is a child class.

UCLASS()

class FPS_API UMultiplayerMovementComponent : public UCharacterMovementComponent

Also my public functions are working on the editor and are not declared with the server specification.

public:

	virtual FNetworkPredictionData_Client* GetPredictionData_Client() const override;

	// UFUNCTION(BlueprintCallable, Category="Movement Sprint")
	void Sprint();

	// UFUNCTION(BlueprintCallable, Category="Movement Sprint")
	void StopSprinting();

	// UFUNCTION(BlueprintCallable, Category="Movement Sprint")
	void Aim();

	// UFUNCTION(BlueprintCallable, Category="Movement Sprint")
	void StopAim();
	
	// UFUNCTION(BlueprintCallable, Category="Movement Sprint")
	bool IsSprinting();

	// UFUNCTION(BlueprintCallable, Category="Movement Sprint")
	bool IsAiming();

BaseCharacter is the class implementing your custom movement component correct?

Do all vitrual override functions call their super counterparts called?

Why should I override the functions on the ABaseCharacter class? the ABaceCharacter class inheirts from the ACharacter class and not from the UMultiplayerMovementComponent, I am just overriding the default UCharacterMovementComponent to the UMultiplayerMovementComponent like this:

ABaseCharacter::ABaseCharacter(const FObjectInitializer& ObjectInitializer)
	: Super( ObjectInitializer.SetDefaultSubobjectClass<UMultiplayerMovementComponent>( ACharacter::CharacterMovementComponentName ) )
{
}

What is weird to me is that this works on the editor even when I run it as “Stand alone” but the error is just during package.

I was referring to custom movement component, it is the class that could contain overrides and is throwing errors. Sorry I should have been more precise with my wording.

If you mean that the functions are implemented on the movement component yes, they are implemented and they just set the flags for the replication:

FNetworkPredictionData_Client* UMultiplayerMovementComponent::GetPredictionData_Client() const
{
	check(PawnOwner != nullptr )

	if ( ClientPredictionData == nullptr )
	{
		UMultiplayerMovementComponent* MutableThis = const_cast<UMultiplayerMovementComponent*>(this);

		MutableThis->ClientPredictionData = new FNetworkPredictionData_Client_Multiplayer(*this);
		MutableThis->ClientPredictionData->MaxSmoothNetUpdateDist = 92.f;
		MutableThis->ClientPredictionData->NoSmoothNetUpdateDist = 140.f;
	}
	
	return ClientPredictionData;
}

void UMultiplayerMovementComponent::Sprint()
{
	bWantsToSprint = true;
}

void UMultiplayerMovementComponent::StopSprinting()
{
	bWantsToSprint = false;
}

void UMultiplayerMovementComponent::Aim()
{
	bWantsToAim = true;
}

void UMultiplayerMovementComponent::StopAim()
{
	bWantsToAim = false;
}

bool UMultiplayerMovementComponent::IsAiming()
{
	return bWantsToAim;
}

bool UMultiplayerMovementComponent::IsSprinting()
{
	return bWantsToSprint;
}

That is the weird part, this works properly on the editor.

Thank you for the help but I just found the problem

Just a reminder that always check your tags #if WITH_EDITOR, for some reason Rider wrapped all my functions with the tag and not only the PostEditChangeProperty.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.