hello.
how can I use Move Component blueprint node in c++.
thx.
It’s in KismetSystemLibrary.h (Engine\Source\Runtime\Engine\Classes\Kismet)
UKismetSystemLibrary::MoveComponentTo(USceneComponent* Component, FVector TargetRelativeLocation, FRotator TargetRelativeRotation, bool bEaseOut, bool bEaseIn, float OverTime, TEnumAsByte<EMoveComponentAction::Type> MoveAction, FLatentActionInfo LatentInfo);
In general, if you have the source you can do “Find In Files”, then the name of the blueprint node without whitespaces (in this case “MoveComponentTo”), set Look In to “Entire Solution” and tell it to search in all *.h files (under “Find options”). The name of whatever default blueprint node you want should come up. Most convenience functions like the one you were searching for will be in the KismetSystemLibrary.
UKismetSystemLibrary is MINIMAL_API and C++ can’t use those functions(it’s functions aren’t exported).
Looking at KismetSystemLibrary.h, MoveComponentTo and the whole class is a member of ENGINE_API, and should work. The following worked for me on version 4.9 when I added this call to one of my actors:
#include "Runtime/Engine/Classes/Kismet/KismetSystemLibrary.h"
...
FLatentActionInfo LatentInfo;
LatentInfo.CallbackTarget = this;
UKismetSystemLibrary::MoveComponentTo(RootComponent, FVector(-961.642578, 790.316956, 494.955322), FRotator(0.0f, 0.0f, 0.0f), false, false, 10.0f, EMoveComponentAction::Type::Move, LatentInfo);
thx.
you solve my problem.
In the new version, 9 parameters required (Docs), adds bForceShortestRotationPath. Total:
FLatentActionInfo LatentInfo;
LatentInfo.CallbackTarget = this;
UKismetSystemLibrary::MoveComponentTo(RootComponent, FVector(0),
FRotator(0), false, false, 0.5f, true,
EMoveComponentAction::Type::Move, LatentInfo);