Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save huckl3b3rry87/572931715de58209fb770bb76e053978 to your computer and use it in GitHub Desktop.
Save huckl3b3rry87/572931715de58209fb770bb76e053978 to your computer and use it in GitHub Desktop.
* Copyright (c) 2018 NVIDIA Corporation.  All rights reserved.        
* This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0
* International License.  (
#pragma once
#include "DomainRandomizationDNNPCH.h"
#include "RandomComponentBase.h"
#include "RandomMovementComponent.generated.h"
UCLASS(Blueprintable, ClassGroup = (NVIDIA), meta = (BlueprintSpawnableComponent))
class DOMAINRANDOMIZATIONDNN_API URandomMovementComponent : public URandomComponentBase
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
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
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
bool bCheckCollision;
UPROPERTY(EditAnywhere, meta=(EditCondition="!bShouldTeleport"))
FFloatInterval RandomSpeedRange;
void BeginPlay() override;
void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
void OnRandomization_Implementation() override;
void OnFinishedRandomization() override;
bool bIsMoving;
FVector TargetLocation;
float CurrentSpeed;
FTransform OriginalTransform;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment