-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathVectorCurveActor.cpp
More file actions
41 lines (28 loc) · 1.1 KB
/
VectorCurveActor.cpp
File metadata and controls
41 lines (28 loc) · 1.1 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
// Fill out your copyright notice in the Description page of Project Settings.
#include "TimelinePluginDemo.h"
#include "VectorCurveActor.h"
void AVectorCurveActor::MoveActor(FVector NewLocation)
{
//Move relative to the initial location
SetActorLocation(PivotPoint + NewLocation);
}
// Sets default values
AVectorCurveActor::AVectorCurveActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
SM = CreateDefaultSubobject<UStaticMeshComponent>(FName("SM"));
TimelineHandleComp = CreateDefaultSubobject<UTimelineHandleComponent>(FName("TimelineHandleComp"));
}
// Called when the game starts or when spawned
void AVectorCurveActor::BeginPlay()
{
Super::BeginPlay();
PivotPoint = GetActorLocation();
//Add a vector curve
TimelineHandleComp->AddCurve(VectorCurve);
//Bind the function that we're going to call in each tick
TimelineHandleComp->OnVectorCurveTickFunction.AddDynamic(this, &AVectorCurveActor::MoveActor);
//Play from start and loop.
TimelineHandleComp->PlayTimelineFromStart(true);
}