forked from Harrison1/unrealcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyInterfaceActorTwo.cpp
More file actions
53 lines (45 loc) · 1.25 KB
/
MyInterfaceActorTwo.cpp
File metadata and controls
53 lines (45 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Harrison McGuire
// UE4 Version 4.20.2
// https://github.com/Harrison1/unrealcpp
// https://severallevels.io
// https://harrisonmcguire.com
#include "MyInterfaceActorTwo.h"
#include "Components/TimelineComponent.h"
// Sets default values
AMyInterfaceActorTwo::AMyInterfaceActorTwo()
{
MyTimeline = CreateDefaultSubobject<UTimelineComponent>(TEXT("My Timeline"));
Name = FString(TEXT("Eddy"));
}
void AMyInterfaceActorTwo::MoveToLocation(float value)
{
SetActorLocation(FMath::Lerp(Start, End, value));
}
void AMyInterfaceActorTwo::ReactToTriggerBegin()
{
IMyInterface::ReactToTriggerBegin();
if (MyCurve)
{
FOnTimelineFloat TimelineCallback;
TimelineCallback.BindUFunction(this, FName("MoveToLocation"));
MyTimeline->AddInterpFloat(MyCurve, TimelineCallback);
MyTimeline->SetLooping(false);
Start = GetActorLocation();
End = Start*5;
MyTimeline->PlayFromStart();
}
}
void AMyInterfaceActorTwo::ReactToTriggerEnd()
{
IMyInterface::ReactToTriggerEnd();
if (MyCurve)
{
FOnTimelineFloat TimelineCallback;
TimelineCallback.BindUFunction(this, FName("MoveToLocation"));
MyTimeline->AddInterpFloat(MyCurve, TimelineCallback);
MyTimeline->SetLooping(false);
End = Start;
Start = GetActorLocation();
MyTimeline->PlayFromStart();
}
}