Skip to content

Commit

Permalink
Updated naming on EQS contexts tut. Added EQS Generators
Browse files Browse the repository at this point in the history
  • Loading branch information
orfeasel committed Oct 16, 2016
1 parent 5402ad3 commit 2d37fa5
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 3 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
48 changes: 48 additions & 0 deletions EQS_Generators/EnvQueryGenerator_Cone.cpp
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);
}
34 changes: 34 additions & 0 deletions EQS_Generators/EnvQueryGenerator_Cone.h
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;
};
5 changes: 5 additions & 0 deletions EQS_Generators/README.md
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
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# UE4-Game-Systems
This repository contains all the code I've written in my website tutorials regarding the implementation of Game Systems inside UE4
# UE4-Cpp-Tutorials
This repository contains all the code I've written in my website tutorials for UE4.

# Systems so far:
- Inventory System ( pickup, equip and drop items)
Expand All @@ -9,4 +9,5 @@ This repository contains all the code I've written in my website tutorials regar
- Skill Tree
- Sniper Elite Cameras
- FlightPath System
- EQS Context
- EQS Context
- EQS Custom Generator

0 comments on commit 2d37fa5

Please sign in to comment.