FRootMotionMovementParams::RootMotionScale linker issue

Hi there,

I’ve been making my own version of the ACharacter and UCharacterMovementComponent classes by pasting contents and changing variable names. At some point I started suffering with the above linker error, which I’ve found other people have stumbled across in this post: here

The problem was related to the use of the FRootMotionMovementParams structure in my copied code (i.e. commenting it out, removed the issue). Looking at the declaration in AnimationAsset.h, I suspect that an insertion of the ENGINE_API macro may solve the issue for me, but I don’t want to change the source code.

Fortunately, root motion isn’t crucial for my project, but it would be nice if this could be rectified so that I easily had the option in future.

Hey -

Can you explain what code you were copying and where you ran into the linker error? Depending on the code being copied/used this seems to be expected behavior. RootMotion is not included by default in order to improve overall compile times, and can be included as necessary. Additionally, if the code being copied contains Editor-Only code, this will cause the project to be unable to package as well. Because of this, it may be best to extend the Character & CharacterMovementComponent classes with the functionality you need for your project rather than trying to copy/recreate them.

Cheers

Hi , not convinced this is desired behaviour, so I’ll just show you quickly how to recreate my issue (using 4.14.2):

  1. Create a new C++ project (I went with First Person example).
  2. Create a new C++ class based on the UPawnMovementComponent.
  3. In this new class, add the following BeginPlay() function.
  4. void UMyPawnMovementComponent::BeginPlay() { FRootMotionMovementParams MyParams; MyParams.ConsumeRootMotion(0.5f); }
  5. Compile.

You will get

1>MyPawnMovementComponent.cpp.obj : error LNK2001: unresolved external symbol “private: static struct FVector FRootMotionMovementParams::RootMotionScale” (?RootMotionScale@FRootMotionMovementParams@@0UFVector@@A)
1>D:\Libraries\Documents\Unreal Projects\MyProject5\Binaries\Win64\UE4Editor-MyProject5-8984.dll : fatal error LNK1120: 1 unresolved externals

(Note, the function called on the FRootMotionMovementParams structure is almost arbitrary, but needs to be a function that involves RootMotionScale somehow. For example, Clear() doesn’t cause a problem, while the above mentioned function and Accumulate both do (plus likely more)).

Hey -

have reproduced this issue and logged a report for it here Unreal Engine Issues and Bug Tracker (UE-40452) . You can track the report’s status as the issue is reviewed by our development staff. Please be aware that this issue may not be prioritized or fixed soon.

I would like to point to additional occurences of this bug ( Unreal Engine Issues and Bug Tracker (UE-40452) ):

It reaches back as far as 4.13:

https://answers.unrealengine.com/questions/480019/unresolved-external-symbol-frootmotionmovementpara.html

https://answers.unrealengine.com/questions/544538/frootmotionmovementparamsrootmotionscale-linker-is.html

The targeted fix says 4.16, but would it be possible to get it into 4.15 still? I have been unable to use my root motion based code since 4.14 and my currently used hotfix is rather unstable.

I am unable to use a custom build of the engine so I cannot implement possible fixes myself.

The bug tracker mentions that removing the static from the declaration fixes it, but it can also be fixed by changing the code to:

static ENGINE_API FVector RootMotionScale;

As suggested by the original poster as well as an answer to my question for 4.13.

Kind Regards

Unfortunately it won’t be possible to get this fix included in time for the 4.15 release, however I have added a note to the original report to indicate the ENGINE_API fix as well as suggest including a fix for this issue in a hotfix.