46 lines
1.1 KiB
C++
46 lines
1.1 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
#pragma once
|
|
|
|
#include "CoreMinimal.h"
|
|
#include "Components/SceneComponent.h"
|
|
#include "MoveComponent.generated.h"
|
|
|
|
|
|
UCLASS(ClassGroup = (Actors), meta = (BlueprintSpawnableComponent))
|
|
class JUMPINGSHIP_API UMoveComponent : public USceneComponent
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
// Sets default values for this component's properties
|
|
UMoveComponent();
|
|
|
|
protected:
|
|
// Called when the game starts
|
|
virtual void BeginPlay() override;
|
|
|
|
public:
|
|
// Called every frame
|
|
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
|
|
|
|
//Offset to move
|
|
UPROPERTY(EditAnywhere)
|
|
FVector MoveOffset;
|
|
private:
|
|
friend class FMoveComponentVisualizer;
|
|
|
|
// Enables the movement of the component
|
|
UPROPERTY(EditAnywhere)
|
|
bool MoveEnable = true;
|
|
//Speed
|
|
UPROPERTY(EditAnywhere)
|
|
float Speed = 1.0f;
|
|
|
|
//Computed locations
|
|
FVector StartRelativeLocation;
|
|
FVector MoveOffsetNorm;
|
|
float MaxDistance = 0.0f;
|
|
float CurDistance = 0.0f;
|
|
float MoveDirection = 1;
|
|
}; |