Skip to content

Commit

Permalink
Updated readme with half baked instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
EPICGameGuy committed Mar 7, 2024
1 parent 2fb6e90 commit e771dea
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Waypoints

Have you ever wanted to make a loop for your UE4 AI guards to patrol, only to find disappointment when you realize that there isn't already a tool like that in Unreal Engine? Well, if that's you, then this is the plugin for you!

![Demonstration](/demonstration.gif)

### Plugin Features

- Easy 2 use
- Free as in freedom
- Free as in free beer

# How to Use the Plugin

1. Put the plugin inside your project's plugins folder and enable it
2. Inside the level editor, drag out a `Waypoint` from the `Place Actors` panel and place it in your level.
3. Click the `Create Waypoint Loop` button inside of the details panel for the Waypoint actor in your level.
4. Hold alt and click and move the Waypoint actor in your level to create the next Waypoint in the loop.
5. Have your AI patrol the Waypoints. todo @nicholas explain this
21 changes: 11 additions & 10 deletions Source/Waypoints/Private/BTTask_MoveToNextWaypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ UBTTask_MoveToNextWaypoint::UBTTask_MoveToNextWaypoint(const FObjectInitializer&
bReachTestIncludesGoalRadius = bReachTestIncludesAgentRadius = GET_AI_CONFIG_VAR(bFinishMoveOnGoalOverlap);
//bAllowStrafe = GET_AI_CONFIG_VAR(bAllowStrafing);

bSetNextWaypointAfterFinishing = true;
bWaitAtCheckpoint = true;

// Accept only waypoints
Expand Down Expand Up @@ -193,16 +194,16 @@ void UBTTask_MoveToNextWaypoint::OnTaskFinished(UBehaviorTreeComponent& OwnerCom
MyMemory->Task.Reset();

// Set the blackboard value to the next waypoint
//if (BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass())
//{
// UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
// UObject* KeyValue = MyBlackboard->GetValue<UBlackboardKeyType_Object>(BlackboardKey.GetSelectedKeyID());
// AWaypoint* TargetActor = Cast<AWaypoint>(KeyValue);
// if (TargetActor)
// {
// MyBlackboard->SetValueAsObject(BlackboardKey.SelectedKeyName, TargetActor->GetNextWaypoint());
// }
//}
if (bSetNextWaypointAfterFinishing && BlackboardKey.SelectedKeyType == UBlackboardKeyType_Object::StaticClass())
{
UBlackboardComponent* MyBlackboard = OwnerComp.GetBlackboardComponent();
UObject* KeyValue = MyBlackboard->GetValue<UBlackboardKeyType_Object>(BlackboardKey.GetSelectedKeyID());

if (AWaypoint* TargetActor = Cast<AWaypoint>(KeyValue))
{
MyBlackboard->SetValueAsObject(BlackboardKey.SelectedKeyName, TargetActor->GetNextWaypoint());
}
}

// Reset the AI's focus
if (AAIController* MyController = OwnerComp.GetAIOwner())
Expand Down
2 changes: 1 addition & 1 deletion Source/Waypoints/Private/Waypoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ AWaypoint::AWaypoint(const FObjectInitializer& ObjectInitializer)
}

bUseCharacterClassNavProperties = true;
CharacterClass = nullptr;
CharacterClass = ACharacter::StaticClass();
}

TArray<TWeakObjectPtr<AWaypoint>> AWaypoint::GetLoop() const
Expand Down
4 changes: 4 additions & 0 deletions Source/Waypoints/Public/BTTask_MoveToNextWaypoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class WAYPOINTS_API UBTTask_MoveToNextWaypoint : public UBTTask_BlackboardBase
{
GENERATED_UCLASS_BODY()

// If true, then the current waypoint will be set to the next waypoint after this task is finished.
UPROPERTY(Category = Node, EditAnywhere)
uint32 bSetNextWaypointAfterFinishing : 1;

UPROPERTY(Category = Node, EditAnywhere)
uint32 bWaitAtCheckpoint : 1;

Expand Down

0 comments on commit e771dea

Please sign in to comment.