Giter Club home page Giter Club logo

navgrid's Introduction

NavGrid

An Unreal Engine 4 plugin for turn based navigation on a grid.

NavGrid supports grids with arbitrary layout including ladders and multiple levels of tiles. This makes it possible to have tile based movement in complex levels, like for instance multi-floor buildings.

Quickstart

The quickest way to get started is probably to download the demo project. The demo contains a sinle level demonstrating flat tiles, ladders and autogenerated virtual tiles.

Compiling

  1. Save/clone into the Plugins/ directory at the project root
  2. Compile. You will need to right click on the .uproject in your project and select Generate Visual Studio project files so VS is aware of the new source files.
  3. Add NavGrid and AIModule to PublicDependencyModuleNames in your .Build.cs

Project Integration

A few more steps are needed after compiling the plugin:

  1. Enable the plugin for your project in the plugin-browser (Edit->Plugins)
  2. Create a Collision Channel in the project setting and set its default response to Ignore
  3. Place some ANavTileActors and a few AExampleGridPawns in your level
  4. Set the PlayerController class to ANavGridPC
  5. Hit Play!

Class Overview

Examining the headers for AGridPawn, ANavGridPC and UGridMovementComponent are probably good starting points for figuring out how this plugin works. You probably want to extend AGridPawn and create you own player controller for your project.

A few of the classes are summarized below.

ANavGrid

Represents the grid. It is responsible for pathfinding.

Useful functions:

  • TilesInRange: Get tiles within the specified distance. Optionally do collision testing and exclude tiles with obstructions.
  • GetTile: Get a tile from world-space coordinates.

Useful events:

  • OnTileClicked
  • OnTileCursorOver
  • OnTileEndCursorOver

Useful properties:

  • ECC_NavGridWalkable: The channel used when tracing for tiles. Set this to the channel you created in step 4 of the quickstart.
  • EnableVirtualTiles: Enables placement of virtual tiles on empty spaces. Useful if you don't want to manually place tiles on every walkable part of your levels.

UNavTileComponent

A single tile that can be traversed by a AGridPawn. It will automaticly detect any neighbouring tiles.

Useful functions:

  • GetNeighbours: Get all neighbouring tiles.
  • Obstructed: Given a capsule and a starting position, is there anything obstructing the movement into this tile?
  • GetUnobstructedNeighbours: Get all neighbouring tiles that a pawn can move into from this tile.
  • Traversable: Given a movement mode and a max walk angle, is it legal to enter this tile?
  • LegalPositionAtEndOfTurn: Given a movement mode and a max walk angle, is it legal to end a turn on this tile?

Useful properties:

  • Cost: The amount of movement expended when moving into this tile.
  • Mesh: Static mesh used for rendering this tile.
  • SelectCursor and HoverCursor: Mesh that can be shown just above the tile as part of the UI.
  • Various *Highlight: Mesh that can be shown just above the tile in order to highlight it in some way.

UNavLadderComponent

A subclass of UNavTileComponent that can be used to represent a ladder.

ANavTileActor and ANavLadderActor

Actor containing a single UNavTileComponent or UNavLadderComponent that can be placed directly into the world.

AGridPawn

Base class for pawns that move on a NavGrid.

Useful functions:

  • OnTurnStart and OnTurnEnd: Called when this pawn's turn begins or ends. Override to add your own code.

Useful properties:

  • CapsuleComponent: The size and relative location of this is used in pathfinding when determening if a tile is obstructed or not.
  • MovementComponent: A UNavGridMovementComponent (described below) for moving on the NavGrid
  • SelectedHighlight: Mesh shown when the pawn is selected.
  • SnapToGrid: Snaps the pawn to grid at game start if set.

UNavGridMovementComponent

A movement component for moving on a navgrid.

Useful functions:

  • CreatePath: Find a path to a tile. Returns false if the tile is unreachable.
  • FollowPath: Follow an existing path.
  • PaseMoving: Temporarily stop moving, call FollowPath to resume.
  • ShowPath: Visualize the path.
  • HidePath: Stop visualizing the path.
  • GetMovementMode: Get the current movement mode (none, walking, climbing up or climping down).

Useful properties:

  • MovementRange: How far (in tile cost) can this pawn move in a single move.
  • Max*Speed: Max speed for various movement modes.
  • bUseRootMotion: Use root motion to determine movement speed. If the current animation does not contain root motion Max*Speed is used instead.
  • AvailableMovementModes: Movement modes available for this pawn. Can be useful if you for instance want to disable climbing for some pawns.

Useful events:

  • OnMovementEnd: Triggered when the pawn has reached its destination.
  • OnMovementModeChanged: Triggered when the movement mode has changed. E.g. when the pawn has started climbing up a ladder instead of walking.

Notes

Temporal Antialiasing

The path preview is thin and changes form and posision from one instance to another. If the antialiasing method is set to TemporalAA, Unreal will attempt to make this motion appear smooth. This might not look good if there is some distance between the camera and the path.

There are two possible solutions to this: Either ensure that the camera is close when drawing a path or change the antialiasing method in Project Settings->Rendering.

Changes

Version 2.2.2 - 23.07.2017

  • Compile even if headers are included in 'incorrect' order
  • Fix building without editor
  • Fix building for Android
  • Handle touch events

Version 2.2.1 - 04.07.2017

  • Place virtual tiles before we do pathfinding
  • Disable shadows for UI elements
  • Use the same height offset for UI elements

Version 2.2 - 05.06.2017

  • Support Unreal Engine 4.16
  • Add automatic placement of 'virtual tiles' on empty areas
  • Add option on ANavGrid for specifying the channel used when tracing for tiles

Version 2.1 - 11.09.2016

  • Support Unreal Engine 4.13
  • Ignore props when deciding if a tile is clicked or hovered over

Version 2.0 - 13.08.2016

  • Support Unreal Engine 4.12
  • Add ladders
  • Add multiple levels of tiles
  • Optionaly use root motion for movement speed

Version 1.0.1 - 29.11.2015

  • Prevent mapcheck warnings about StaticMesh attributes being NULL when building

Version 1.0 - 08.11.2015

  • First version

navgrid's People

Contributors

larsjsol avatar miru302 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

navgrid's Issues

GridPawn.cpp: State->Grid is NULL when 2 or more players

Hi!

I'm attempting to alter the code a bit to make it work for a multiplayer game, but I've been running into this issue when the player count is increased to 2 or more (State->Grid is NULL.) This holds true for the original plugin without any of the edits I've made to it. I'm a bit stumped as to why this error is occurring other than perhaps multiple game states are being made when there is more than one player and one of the states is not being initialized correctly. That seems unlikely though, I would think only one game state is created. Anyway, if you have any idea as to what might be causing this I'd appreciate the input. Thanks!

void AGridPawn::BeginPlay()
{
	Super::BeginPlay();
	auto *State = GetWorld()->GetGameState<ANavGridGameState>();
	check(State && State->Grid);
	Grid = State->Grid;
	SelectedHighlight->SetRelativeLocation(FVector(0, 0, Grid->UIOffset));

	ATurnManager *TM = State->GetTurnManager(TeamID);
	check(TM);
	TM->Register(TurnComponent);

	if (SnapToGrid)
	{
		MovementComponent->SnapToGrid();
	}
}

LGPL License is against Unreal EULA

The license you've selected for this is incompatible and against Unreal EULA.

  1. Other Restrictions on Your Use of the Licensed Technology
    a. Non-Compatible Licenses
    You may not, and may not permit others to, combine, Distribute, or otherwise use the Licensed Technology with any code or other content which is covered by a license that would directly or indirectly require that all or part of the Licensed Technology be governed under any terms other than those of this Agreement (those licenses, the “Non-Compatible Licenses”). This means, for example, that you may not combine the Licensed Technology with code or content that is licensed under any of the following licenses: GNU General Public License (GPL), Lesser GPL (LGPL) (unless you are merely dynamically linking a shared library), or Creative Commons Attribution-ShareAlike License.

https://www.unrealengine.com/en-US/eula/unreal

Integration problem

Hello, I cant understand .Do not display all classes when adding a plug-in "http://imgur.com/JJSBgoI" ,Could you please explain this point in detail. I would like to see more examples,Thank you for help

Incompatible with UE4 versions 4.16.3 and 4.17.1

Hey would it be possible to update the plugin to either 4.16.3 or 4.17.1?

I am getting an version incompatibility error when I enable the plugin and restart the editor under the specified versions.

Problem with build NavGridDemo

Hello, thank you for such a long support of this project. but now i am getting problem with build a last NavGridDemo with unreal 4.25.0 , i am attaching a logs
https://dropmefiles.com/ReYUD

and i am changed build.cs like
`using UnrealBuildTool;
using System.IO;

public class NavGrid : ModuleRules
{
public NavGrid(ReadOnlyTargetRules TargetRules) : base(TargetRules) {

    PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
    PublicIncludePaths.Add (Path.Combine (ModuleDirectory, "Public")); 
    PublicIncludePaths.Add (Path.Combine (ModuleDirectory, "Classes")); 
    PrivateIncludePaths.Add (Path.Combine (ModuleDirectory, "Private")); 
    
            PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "AIModule" });

    if (TargetRules.bBuildEditor)
    {
        PrivateDependencyModuleNames.AddRange(new string[] { "UnrealED" });
    }

}

}`

Linking errors when creating empty class derived from GridPawn

Hi!

I'm attempting to make a class derived from GridPawn.

#pragma once

#include "CoreMinimal.h"
#include "Classes/GridPawn.h"
#include "DSExampleGridPawn.generated.h"

UCLASS()
class DRAGONSPINE_API ADSExampleGridPawn : public AGridPawn
{
	GENERATED_BODY()

public:	
	
};

Whenever I attempt to compile however I'm getting these linking errors which seem to imply the GetTeamAttitudeTowards function in UE_4.19\Engine\Source\Runtime\AIModule\ClassesGenericTeamAgentInterface.h
of the Engine is undefined.

DSExampleGridPawn.cpp.obj : error LNK2001: unresolved external symbol "public: virtual enum ETeamAttitude::Type __cdecl IGenericTeamAgentInterface::GetTeamAttitudeTowards(class AActor const &)const " (?GetTeamAttitudeTowards@IGenericTeamAgentInterface@@UEBA?AW4Type@ETeamAttitude@@AEBVAActor@@@Z) DSExampleGridPawn.gen.cpp.obj : error LNK2001: unresolved external symbol "public: virtual enum ETeamAttitude::Type __cdecl IGenericTeamAgentInterface::GetTeamAttitudeTowards(class AActor const &)const " (?GetTeamAttitudeTowards@IGenericTeamAgentInterface@@UEBA?AW4Type@ETeamAttitude@@AEBVAActor@@@Z)

Which it is of course. I've been trying to figure out why this might be happening all day, but haven't really been able to find anything substantial. You wouldn't happen to have ant idea why this might be happening would you? Thanks for your time and sorry to bother you.

What is the lisense?

I was going to start working on something very similar to this because the advanced tactics on the UE store is built only using blue prints and the creator is not interested in releasing it open source. I wanted to know what it is before I start work since it doesn't seem to be specified and there is no license file.

Public domain? MIT? BSD? GPL?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.