-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFloatingPlatform.cpp
More file actions
48 lines (34 loc) · 1.34 KB
/
Copy pathFloatingPlatform.cpp
File metadata and controls
48 lines (34 loc) · 1.34 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
// Fill out your copyright notice in the Description page of Project Settings.
#include "FloatingPlatform.h"
// Sets default values
AFloatingPlatform::AFloatingPlatform()
{
// 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;
}
// Called when the game starts or when spawned
void AFloatingPlatform::BeginPlay()
{
Super::BeginPlay();
// FTransform ActorTransform = GetTransform();
// FVector Location = ActorTransform.GetLocation();
//FVector ActorLocation = FVector(10.f, 20.f, 30.f);
//SetActorLocation(ActorLocation);
// ActorTransform.GetTranslation();
// ActorTransform.GetRotation();
// ActorTransform.GetScale3D();
}
// Called every frame
void AFloatingPlatform::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if (controlledPlatform == true)
{
FVector NewLocation = GetActorLocation(); // Get Location of Actor
float DeltaHeight = (FMath::Sin(RunningTime + DeltaTime) - FMath::Sin(RunningTime)); // Perform FMath function to move the object
NewLocation.Y += DeltaHeight * RunningSpeed; //Scale our height by a factor of Running Speed (float)
RunningTime += DeltaTime;
SetActorLocation(NewLocation);
UE_LOG(LogTemp, Warning, TEXT("Sin(RunningTime = %f"), DeltaHeight);
}
}