I'm trying to use iTween (via C++, not BP) to rotate an actor to face another, but it throwing an exception in Actor.h that says:
I'm using the following code to start the tween:
AActor* actorToRotate = Cast<AActor>(this);
if (actorToRotate != nullptr && CharacterToAttack != nullptr)
{
FRotator rotationFrom = actorToRotate->GetActorRotation();
FRotator rotationTo = CharacterToAttack->GetActorRotation();
FName tweenName = TEXT("turret");
AiTweenEvent* TurretTween = UiTween::ActorRotateFromToSimple(tweenName, actorToRotate, rotationFrom, rotationTo, CoordinateSpace::world, false, 2.0f, easeInAndOutQuartic);
}
Rather than using the actorToRotate variable I've tried using this in ActorRotateFromToSimple() but I get the same error.
if (CharacterToAttack != nullptr)
{
FRotator rotationFrom = GetActorRotation();
FRotator rotationTo = CharacterToAttack->GetActorRotation();
FName tweenName = TEXT("turret");
AiTweenEvent* TurretTween = UiTween::ActorRotateFromToSimple(tweenName, this, rotationFrom, rotationTo, CoordinateSpace::world, false, 2.0f, easeInAndOutQuartic);
}
If anyone smarter than me shed some light onto this issue it would be greatly appreciated.
Additional information I think might be important:
actorToRotateis custom type ofATDWeaponthat extends fromAActorCharacterToAttackis custom type ofATDAICharacterthat extends fromATDCharacter- The function that executes this code is called by
GetWorldTimerManager().SetTimer() - I've added
#include "iTween/iTween.h"to the top of myTDWeapon.cppfile

Ah, the problem wasn't in the code. I was using "simulate in editor" in the UE4 Editor rather than "play in editor".
It appears that
AiTweenEvent* UiTween::SpawnEvent(AiTAux* aux)needs a player controller and usesGetWorldLocal()->GetFirstPlayerController()->GetPawn()->GetTransform()to get it's transform. In my instance, "simulate in editor" doesn't spawn a player soGetPawn()returnsnullptrwhichGetTransform()doesn't like.Awesome.