Skip to content

I made the flowfield project in UE4 c++ to learn and improve my UE4 c++ skills

Notifications You must be signed in to change notification settings

WouterServaes/FlowfieldUE

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FlowfieldUE

Connect with me on LinkedIn!

View my portfolio here!

Table of contents

Info

I decided to make a second project surrounding flowfields, this time using a full engine. When I started this project, Unity seemed like the obvious choice. Development is fast and pretty easy, I have experience with it. In the end, I decided to make it in UE4 using c++. I did this to learn more about the engine and to improve my c++ in UE4. The UI and character controller use blueprints, I exposed some c++ functions to the editor for this reason. Gif of project Images of project Images of project

Overview

Spawner

Agent spawner objects can be placed in the world. You can change some settings, like the amount of agent this spawner spawns, a reference to the grid it uses, a reference to the agent handler it should use, the agent spawn height and the time between each agent spawn. Code

Goal

Goals can be placed in the world too. For every goal, a flowfield is generated. Every agent is assigned a random goal when spawned. Goals are simple objects with no functionality, the grid simply saves the position of each goal at the start.

Grid

Grid objects are the playing field of the agents. All the squares of the grid know their column, row, bottom left position, all flow directions and the type of the square. The agents access the grid to know in what direction they have to go. The size of the grid can be set in the settings. A goal actor is given to the grid too, to find all the goals on the grid. This is the same for obstacles. Code

Obstacles

The obstacles can be whatever actors with a mesh. Before the flowfield is generated, the grid detects what squares should be marked as obstacle by checking if an obstacle mesh is inside the square. Code

Agent handler

The agent handler spawns and removes the agents. It only removes the agents once every agent has reached its goal. When an agent reaches its goal, the agents gets deactivated but remains in memory. When a new agents should be spawned, it checks if there are any removed agents and respawns one if this is the case. It spawns a new agent if there are no removed agents. Code

Agents

The agent actor is a normal actor with a mesh and an AgentAI component. This component handles the movement of the agent using a reference to the grid. It also does some checks using the grid reference (whether it's outside the grid or if it arrived at a goal). Code

Original project

The original project can be found here. That was made in a private engine using c++.

Conclusion

The project performs well when the agents are spawning slowly. It freezes for some time when they all spawn at once on random positions. The project is missing some handy features like spawning, moving and selecting agents, and placing and moving obstacles.

End

Connect with me on LinkedIn!

About

I made the flowfield project in UE4 c++ to learn and improve my UE4 c++ skills

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published