forked from orfeasel/UE4-Cpp-Tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated naming on EQS contexts tut. Added EQS Generators
- Loading branch information
Showing
10 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
#include "EqsTut.h" | ||
#include "EnvQueryGenerator_Cone.h" | ||
|
||
|
||
|
||
|
||
void UEnvQueryGenerator_Cone::GenerateItems(FEnvQueryInstance& QueryInstance) const | ||
{ | ||
//This array will hold a reference to all the generated items, meaning, the cone items | ||
TArray<FNavLocation> ItemCandidates; | ||
|
||
//Get a reference for our AI Pawn | ||
AActor* AIPawn = Cast<AActor>((QueryInstance.Owner).Get()); | ||
|
||
//Store its location and its forward vector | ||
FVector PawnLocation = AIPawn->GetActorLocation(); | ||
FVector PawnForwardVector = AIPawn->GetActorForwardVector(); | ||
|
||
//If the angle step is zero we're going into an infinite loop. | ||
//Since we don't want that, don't execute the following logic | ||
if (AngleStep == 0) return; | ||
|
||
for (float Angle = -ConeDegrees; Angle < ConeDegrees; Angle += AngleStep) | ||
{ | ||
//Start from the left side of the pawn and rotate its forward vector by Angle + 1 | ||
FVector LeftVector = PawnForwardVector.RotateAngleAxis(Angle + 1, FVector(0, 0, 1)); | ||
//The Left Vector is showing a straight line for that angle. The only thing we need | ||
//is to generate items in that line | ||
|
||
//Generates all the points for the current line (LeftVector) | ||
for (int32 Point = 0; Point < ConeRadius; Point++) | ||
{ | ||
//Generate a point for this particular angle and distance | ||
FNavLocation NavLoc = FNavLocation(PawnLocation + LeftVector * Point * PointsDistance); | ||
|
||
//Add the new point into our array | ||
ItemCandidates.Add(NavLoc); | ||
} | ||
} | ||
|
||
//Projects all the nav points into our Viewport and removes those outside of our navmesh | ||
ProjectAndFilterNavPoints(ItemCandidates, QueryInstance); | ||
|
||
//Store the generated points as the result of our Query | ||
StoreNavPoints(ItemCandidates, QueryInstance); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Fill out your copyright notice in the Description page of Project Settings. | ||
|
||
#pragma once | ||
|
||
#include "EnvironmentQuery/Generators/EnvQueryGenerator_ProjectedPoints.h" | ||
#include "EnvQueryGenerator_Cone.generated.h" | ||
|
||
/** | ||
* | ||
*/ | ||
UCLASS() | ||
class EQSTUT_API UEnvQueryGenerator_Cone : public UEnvQueryGenerator_ProjectedPoints | ||
{ | ||
GENERATED_BODY() | ||
|
||
/** Generates items in a cone and places them in the environemtn */ | ||
virtual void GenerateItems(FEnvQueryInstance& QueryInstance) const override; | ||
|
||
/* The distance between each point of the same Angle */ | ||
UPROPERTY(EditAnywhere, Category = ConeProperties) | ||
float PointsDistance = 50.f; | ||
|
||
/* The maximum degrees of the generated cone */ | ||
UPROPERTY(EditAnywhere, Category = ConeProperties) | ||
float ConeDegrees = 20.f; | ||
|
||
/* Angle Step is the step that the angles increase. A small value means that more item will get generated */ | ||
UPROPERTY(EditAnywhere, Category = ConeProperties) | ||
float AngleStep; | ||
|
||
/* The radius of our cone */ | ||
UPROPERTY(EditAnywhere, Category = ConeProperties) | ||
float ConeRadius = 150.f; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
EQS Generator Tutorial | ||
|
||
Check the end result here: https://youtu.be/imTTYF9eoNc | ||
|
||
Read the full tutorial here: http://wp.me/p6hvtS-hV |
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