forked from Harrison1/unrealcpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRotateAroundVector.cpp
More file actions
44 lines (31 loc) · 1.03 KB
/
RotateAroundVector.cpp
File metadata and controls
44 lines (31 loc) · 1.03 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
// Harrison McGuire
// UE4 Version 4.20.2
// https://github.com/Harrison1/unrealcpp
// https://severallevels.io
// https://harrisonmcguire.com
#include "RotateAroundVector.h"
// Sets default values
ARotateAroundVector::ARotateAroundVector()
{
// 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;
AngleAxis = 0;
}
// Called every frame
void ARotateAroundVector::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
// declare arbitrary vector point in the world to circle around
FVector NewLocation = FVector (0,0,800);
// declare size of radius to move around
FVector Radius = FVector(200,0,0);
// angle increases by 1 every frame
AngleAxis++;
// prevent number from growind indefinitely
if(AngleAxis > 360.0f) AngleAxis = 1;
FVector RotateValue = Radius.RotateAngleAxis(AngleAxis, FVector (0,0,1));
NewLocation.X += RotateValue.X;
NewLocation.Y += RotateValue.Y;
NewLocation.Z += RotateValue.Z;
SetActorLocation(NewLocation);
}