Created
May 27, 2020 21:21
-
-
Save huckl3b3rry87/572931715de58209fb770bb76e053978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (c) 2018 NVIDIA Corporation. All rights reserved. | |
* This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 | |
* International License. (https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode) | |
*/ | |
#pragma once | |
#include "DomainRandomizationDNNPCH.h" | |
#include "RandomComponentBase.h" | |
#include "RandomMovementComponent.generated.h" | |
/// @cond DOXYGEN_SUPPRESSED_CODE | |
UCLASS(Blueprintable, ClassGroup = (NVIDIA), meta = (BlueprintSpawnableComponent)) | |
/// @endcond DOXYGEN_SUPPRESSED_CODE | |
class DOMAINRANDOMIZATIONDNN_API URandomMovementComponent : public URandomComponentBase | |
{ | |
GENERATED_BODY() | |
public: | |
URandomMovementComponent(); | |
AVolume* GetRandomLocationVolume() const | |
{ | |
return RandomLocationVolume; | |
} | |
void SetRandomLocationVolume(AVolume* NewVolume, bool bForceUseVolume = false); | |
protected: // Editor properties | |
// If true, the owner will be moving around its original location | |
// Otherwise the random location will be selected in the RandomLocationVolume | |
UPROPERTY(EditAnywhere) | |
bool bRelatedToOriginLocation; | |
UPROPERTY(EditAnywhere, meta = (EditCondition = "bRelatedToOriginLocation")) | |
FRandomLocationData RandomLocationData; | |
// If true, the location will be picked along the object's axes instead of the world axes | |
UPROPERTY(EditAnywhere, meta = (EditCondition = "bRelatedToOriginLocation")) | |
bool bUseObjectAxesInsteadOfWorldAxes; | |
// The volume to choose a random location from | |
UPROPERTY(EditAnywhere, meta = (EditCondition = "!bRelatedToOriginLocation")) | |
AVolume* RandomLocationVolume; | |
// If true, the actor will instantly teleport whenever location changed | |
// otherwise the object will move toward the new location with speed in the RandomSpeedRange | |
UPROPERTY(EditAnywhere) | |
bool bShouldTeleport; | |
// If true, the actor will not be able to move if its way is blocked | |
// Otherwise the actor can go through other object or teleport overlap with the other | |
UPROPERTY(EditAnywhere) | |
bool bCheckCollision; | |
UPROPERTY(EditAnywhere, meta=(EditCondition="!bShouldTeleport")) | |
FFloatInterval RandomSpeedRange; | |
protected: | |
void BeginPlay() override; | |
void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; | |
void OnRandomization_Implementation() override; | |
void OnFinishedRandomization() override; | |
protected: | |
bool bIsMoving; | |
FVector TargetLocation; | |
float CurrentSpeed; | |
UPROPERTY(Transient) | |
FTransform OriginalTransform; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment