2021-01-19 15:25:56 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "CoreMinimal.h"
|
|
|
|
#include "GameFramework//Actor.h"
|
|
|
|
#include "Components/ActorComponent.h"
|
|
|
|
#include "MovingActor.generated.h"
|
|
|
|
|
|
|
|
|
|
|
|
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
|
|
|
|
class BUILDINGESCAPE_API UMovingActor : public UActorComponent
|
|
|
|
{
|
|
|
|
GENERATED_BODY()
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Sets default values for this component's properties
|
|
|
|
UMovingActor();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
// Called when the game starts
|
|
|
|
virtual void BeginPlay() override;
|
|
|
|
|
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
void Move();
|
|
|
|
|
2021-02-02 18:18:51 +01:00
|
|
|
UFUNCTION(BlueprintCallable)
|
|
|
|
void MoveBack();
|
|
|
|
|
2021-01-19 15:25:56 +01:00
|
|
|
public:
|
|
|
|
// Called every frame
|
|
|
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType,
|
|
|
|
FActorComponentTickFunction* ThisTickFunction) override;
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
float MovementSpeed = 15.f;
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
float MovementTarget = 10.f;
|
|
|
|
|
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
bool Negative = false;
|
|
|
|
|
2021-02-02 14:09:40 +01:00
|
|
|
UPROPERTY(EditAnywhere)
|
|
|
|
bool Up = false;
|
|
|
|
|
2021-01-19 15:25:56 +01:00
|
|
|
private:
|
2021-02-02 18:18:51 +01:00
|
|
|
bool moving = false;
|
2021-01-19 15:25:56 +01:00
|
|
|
bool soundHasBeenPlayed;
|
|
|
|
FVector targetLocation;
|
|
|
|
FVector tempLocation;
|
2021-02-02 18:18:51 +01:00
|
|
|
|
|
|
|
void PlaySound();
|
2021-01-19 15:25:56 +01:00
|
|
|
};
|