UE5.4 State Tree Data Management

MrKosiej
29 Apr 202427:25

Summary

TLDRThe video transcript discusses various methods for managing data within Unreal Engine's State Trees. The speaker starts by mentioning changes in the latest version (5.4) and then delves into the topic of data management, which is not frequently covered. They explore the concept of using a separate U object or a derived object to store data, suggesting the creation of a blueprint class called 'BP Store' for this purpose. The speaker also touches upon the use of Blackboards, traditionally associated with Behavior Trees, and how they can be utilized with State Trees. A new feature in Unreal Engine 5.4 is highlighted – the State Tree AI Component, which allows for easier access to the AI controller class and can be used for data management. The video concludes with an innovative idea of storing data directly in the State Tree component, akin to using a Blackboard, and demonstrates a practical example of tracking and displaying an AI character's movement history within the game environment. This approach is presented as a versatile solution for both AI and non-AI actors.

Takeaways

  • 📚 The video discusses data management within Unreal Engine 5.4's State Trees, a topic not extensively covered online but mentioned in the comments of a previous video.
  • 🔍 The presenter suggests using a separate U object or a derived object to store data, which can then be utilized within the State Tree for managing variables.
  • 📦 An alternative method involves using a Blackboard, a concept traditionally associated with Behavior Trees in Unreal Engine, which can also be experimented with in State Trees.
  • 🆕 Unreal Engine 5.4 introduces a new schema for State Trees, the 'State Tree AI Component', which provides direct access to the AI controller class.
  • 💡 The presenter proposes a novel idea of storing data directly within the State Tree component, effectively using it as a Blackboard, which simplifies data management.
  • 🚀 A custom C++ class is created to extend the functionality of the State Tree component, making it accessible and mutable within Blueprints for easier data management.
  • 🛠️ The presenter demonstrates how to compile and use the custom State Tree component in C++, emphasizing the need to include specific modules for successful compilation.
  • 🔑 The new component allows for the storage of data in a map structure, similar to a Blackboard, which can be manipulated using Blueprints for a more visual and intuitive experience.
  • 📈 An example is provided where the component is used to store and visualize the history of an AI character's visited locations, showcasing the practical application of the data management method.
  • 🌟 The video concludes with an invitation for viewers to share their own ideas on managing data in State Trees, encouraging community engagement and further exploration of the topic.
  • ➡️ The presenter highlights the flexibility of the method, which works with both AI and non-AI actors, and emphasizes the ease of use by integrating directly with the State Tree component.

Q & A

  • What is the main topic of discussion in the video?

    -The main topic of discussion in the video is data management within Unreal Engine's State Trees.

  • What is the first method suggested for managing data in State Trees?

    -The first method suggested involves using a separate U object or deriving from a U object to store data, such as creating a blueprint class named 'BP Store' to hold variables.

  • What is the role of a global task in the first method of data management?

    -In the first method, a global task is used to create or construct an object from the 'BP Store' class when the state tree initializes.

  • What is a straightforward way to store data in Unreal Engine?

    -A straightforward way to store data is to add variables directly to the class of the character that the state tree is being used on and then access these variables through the context actor.

  • What is a Blackboard in Unreal Engine?

    -A Blackboard in Unreal Engine is an asset used traditionally with Behavior Trees to store data. It contains keys that can be set or retrieved to manage data across different parts of the AI system.

  • How can Blackboards be used with State Trees?

    -Blackboards can be used with State Trees by using an AI controller to link the State Tree to the Blackboard. However, this method is more commonly associated with Behavior Trees and may require additional steps to integrate with State Trees.

  • What is new in Unreal Engine 5.4 regarding State Trees?

    -Unreal Engine 5.4 introduces a new schema called 'State Tree AI Component' which allows for the creation of different kinds of state tree assets with direct access to the AI controller class.

  • What is the proposed alternative method for data management without using a Blackboard, actor class, or constructing a new object?

    -The proposed alternative method is to store data directly in the State Tree component, using it as a Blackboard to manage and store variables.

  • How does creating a custom C++ class for the State Tree component help with data management?

    -Creating a custom C++ class for the State Tree component allows for the exposure of specific variables and functions to Blueprints, enabling the storage of data within the component in a structured manner similar to a Blackboard.

  • What is the benefit of storing data in the State Tree component?

    -Storing data in the State Tree component allows for a centralized location for data management that is automatically initialized with the component, making it convenient and reducing the need for manual setup or initialization.

  • How does the video demonstrate the practical use of the new data management method?

    -The video demonstrates the practical use by showing how to store and replay the history of visited locations of an AI character using the map vector within the State Tree component.

Outlines

00:00

📘 Introduction to Unreal Engine 5.4 and Data Management

The speaker begins by welcoming the audience to Unreal Engine 5.4 and mentions that they previously worked with a preview version. They note that while many things have changed, they will only discuss one significant change related to the topic of the day, which is data management. The speaker briefly mentions a comment from a viewer about managing data in state trees and suggests using a separate U object or a blueprint class to store variables. They also touch upon the concept of creating a global task within a state tree to manage data.

05:02

📚 Exploring Data Storage Options in Unreal Engine

The speaker discusses different methods for storing data within Unreal Engine, such as using an actor class or a new object within the state tree. They also mention the use of blackboards, a feature traditionally associated with behavior trees, and how they can be used with state trees. The speaker highlights a new schema introduced in Unreal Engine 5.4, the state tree AI component, which provides direct access to an AI controller class and allows for more complex data management.

10:04

💡 Innovative Data Management Using State Tree Components

The speaker shares their idea of managing data by storing it directly in the state tree component, similar to using a blackboard. They explain the process of creating a custom state tree component in C++ and exposing it to blueprints to allow for data storage. The speaker demonstrates how to add variables to the component and how these can be used to store and manage data within the state tree.

15:06

🛠️ Creating a Custom State Tree Component in C++

The speaker provides a step-by-step guide on how to create a custom state tree component in C++ and make it accessible in blueprints. They discuss the importance of adding necessary modules for the project to compile successfully. The speaker also shows how to implement functions to get and set the state tree asset from within the custom component.

20:07

🔍 Storing and Retrieving Data with the Custom Component

The speaker illustrates how to use the custom state tree component to store and retrieve data. They demonstrate adding a map vector to the component, which can be used to store vectors as keys and values. The speaker also shows how to access the component from a blueprint class and how to store and manage data using this method.

25:10

🚀 Implementing a Data History Feature with the Custom Component

The speaker presents an example of using the custom state tree component to implement a data history feature. They explain how to store visited locations in a map vector and then use this data to draw debug lines, showing the history of the character's movements. This example demonstrates the utility of the custom component for managing data in both AI and non-AI actors.

Mindmap

Keywords

💡Unreal Engine 5.4

Unreal Engine 5.4 is a version of the popular game development platform Unreal Engine, which provides tools and features for creating interactive experiences and games. In the video, the speaker discusses changes and updates from the preview version to the release version, indicating its relevance to the development process discussed.

💡Data Management

Data management refers to the process of organizing, storing, and maintaining the data of a project or system. In the context of the video, it is a central theme as the speaker explores different methods for managing data within state trees in Unreal Engine, which is crucial for game logic and AI behavior.

💡State Trees

State trees are a feature in Unreal Engine used for managing the state and behavior of AI or other game characters. The video focuses on how to manage data within these state trees, showcasing different approaches and their implications for game development.

💡Blueprint Class

A blueprint class in Unreal Engine is a visual scripting system that allows developers to design game logic without writing code. The speaker mentions creating a blueprint class called 'BP Store' to store variables, demonstrating a method for data management within the engine.

💡Blackboard

A blackboard is a data structure used in behavior trees for AI in Unreal Engine. It stores key-value pairs that can be accessed and modified by the AI. The video discusses using blackboards as an alternative method for data management, tying into the overall theme of the video.

💡AI Controller

The AI controller is a component in Unreal Engine that manages the AI associated with a character or object. It is mentioned in the context of using state trees with AI, and how the new State Tree AI Component schema in Unreal Engine 5.4 provides direct access to the AI controller class for enhanced data management.

💡C++

C++ is a programming language often used for system programming and game development. The speaker discusses creating a custom state tree component in C++ to expose certain functionalities to blueprints, highlighting the need to sometimes use C++ for tasks that cannot be accomplished within the blueprint visual scripting environment.

💡Component

In Unreal Engine, a component is a modular part of an actor that can define its properties and behaviors. The video explores the idea of using components, specifically a custom state tree component, as a means for data storage and management within the engine.

💡Maps

Maps, in the context of this video, refer to data structures that store data in a key-value pair format. The speaker creates a map within a state tree component to store vectors, demonstrating a method for tracking data such as AI character positions over time.

💡Debugging

Debugging is the process of finding and resolving defects or issues in a software program. The video uses 'draw debug line' as an example of how to visualize the history of an AI character's movements by drawing lines between stored positions, illustrating the practical application of data management in debugging and development.

💡Behavior Trees

Behavior trees are a type of AI system used in game development for defining the behavior of non-player characters. The video contrasts state trees with behavior trees, positioning state trees as an advanced version and discussing how blackboards traditionally used with behavior trees can also be utilized with state trees.

Highlights

Introduction to Unreal Engine 5.4 and its changes from the preview version.

Discussion on data management in state trees, a topic not widely covered but requested by viewers.

Suggestion to use a separate U object or a derived object to store data for state management.

Explanation of creating a blueprint class called 'BP Store' to hold variables like test Boolean and test float.

Demonstration of using a global task to construct an object from the 'BP Store' class within a state tree.

Alternative methods for data storage in state trees as opposed to using the character class directly.

Introduction of using Blackboards, traditionally used with Behavior Trees, with State Trees.

Description of Blackboards as assets with keys for storing data and their potential use with State Trees.

Mention of a new schema in State Trees 5.4 for AI, providing direct access to an AI controller class.

Proposal to store data directly in the State Tree component as an alternative to using a Blackboard or actor class.

Walkthrough of creating a custom State Tree component in C++ for exposing to blueprints.

Explanation of adding a map vector to the custom State Tree component for data storage.

Demonstration of storing visited locations in the map vector and drawing debug lines to show the history.

Discussion on the flexibility and potential applications of this data management method for both AI and non-AI actors.

Advantages of this approach, including the ease of use and automatic initialization with the State Tree component.

Encouragement for viewers to share their ideas on managing data in state trees.

Invitation for viewers to like, comment, and subscribe for more in-depth videos on Unreal Engine.

Transcripts

play00:00

hi am here and welcome to Unreal Engine

play00:02

5.4 in the release version last few

play00:05

videos we worked with preview version

play00:08

some things changed I'm not going to

play00:10

talk about all of them uh but I am going

play00:14

to talk about one but it's not the topic

play00:17

of this video it's just you know a side

play00:20

subject I'm going to just mention

play00:22

quickly because it's kind of related to

play00:24

what I'm going to be talking about today

play00:27

but it's not the uh the main part

play00:30

okay so what is the today's topic well

play00:34

it's data management and uh

play00:39

well this is a topic I have seen uh kind

play00:44

of mentioned not a lot but a little bit

play00:47

uh on internet and uh actually somebody

play00:52

mentioned uh mentioned this in the

play00:54

comments of my 5.3 updates video and

play00:59

this guy

play01:02

mentioned well data management in state

play01:06

trees and you can you know kind of read

play01:11

or just go to that video watch it and

play01:13

then read the comments and and see what

play01:16

you think about them uh about those

play01:19

those comments but uh in just the

play01:21

conversation were about uh how do you

play01:24

manage data in in States right and one

play01:30

kind of uh one kind of way I suggested

play01:33

that we could go about this uh was using

play01:36

a separate um a separate U object or

play01:41

just object or maybe a different kind of

play01:44

object you derive from you object and

play01:48

just store data there so the principle

play01:51

would be like you make a blueprint class

play01:54

you make uh just an object uh you call

play01:57

that object BP store or or what ever and

play02:00

in that object you just you know store

play02:02

some variables like uh test Boolean test

play02:07

test

play02:08

flat and so and so on and in the actual

play02:13

state tree you would just you know uh

play02:17

probably make a global task and in that

play02:20

task you could you could probably make a

play02:22

new state three

play02:24

task right and in that task you say s

play02:31

init and in that init on enter State you

play02:34

will just you know create

play02:37

object or construct rather

play02:41

construct I can't write today construct

play02:44

object from class

play02:46

pick. store

play02:48

class right I I can't even hit

play02:53

it as store BP store right and just you

play03:00

know promote

play03:02

variable put that to H to an

play03:07

output I I need to

play03:09

focus

play03:11

output category uh and

play03:14

then you

play03:16

would put it here and now we have Star

play03:21

as output and then if we wanted to uh

play03:25

you know make another state state would

play03:27

be like move and mve to yes move to and

play03:32

in that task we would add let's say move

play03:35

to and we could just pass that uh store

play03:39

to that task and maybe store some

play03:41

variables in that uh object right so

play03:44

it's like one of ways you could go about

play03:48

storing uh

play03:50

data uh and of course this is all an

play03:53

alternative to what you would normally

play03:55

do normally do if you would want to

play03:58

store some data because the very

play04:00

straightforward and the most

play04:02

straightforward straightforward way

play04:04

would be to um go to Just class of the

play04:09

character you are using the state Tri on

play04:12

and just you know store variables there

play04:15

and then when you use that task you just

play04:19

you

play04:20

know uh context actor

play04:23

right take that

play04:26

context

play04:28

actor and uh put a class there and just

play04:33

you know take it

play04:35

out and just you know set set variables

play04:38

right but uh the reason we are talking

play04:41

about Alternatives is that maybe we

play04:44

don't necessarily want to St uh store

play04:48

variables straight in that in that actor

play04:52

right so we are kind of you know

play04:54

chilling today and desing a few

play04:56

different ways we could go about doing

play04:58

this and uh yeah we're just going to

play05:02

chill and see what else we can do so my

play05:08

option well before we go to the next

play05:11

part I of course encourage you to watch

play05:14

my video about stries last state trees

play05:17

video where I actually made those State

play05:20

trees uh I showed linked assets I showed

play05:25

um some other updates colors and stuff

play05:29

of new stuff that came from uh Unreal

play05:32

Engine 5.4 in preview version and you

play05:38

would know why do I have those assets

play05:41

and why they are struct structured like

play05:44

that and uh okay moving

play05:48

on how do you store data well either an

play05:52

actor class or what I just show you so a

play05:56

new object that you can just in it in uh

play06:00

the state tree or you could do what this

play06:03

guy did and this guy did uh

play06:08

basically he went back to uh to the

play06:11

Blackboard and blackboards if you are

play06:14

not aware blackwards are used or were

play06:17

used or

play06:18

both uh with behavior trees so Behavior

play06:22

trees are uh I would say but you can

play06:27

like not agree with me it's a like

play06:31

version of uh you know doing AI in

play06:36

Unreal Engine because uh I consider

play06:38

State trees to be superior and you know

play06:42

an xgen version of behavior trees and

play06:44

behavior

play06:46

trees traditionally used and still used

play06:49

if you want to use Behavior trees today

play06:52

uh blackboards and blockboards are types

play06:54

of assets that are kind of tied to uh

play06:58

Behavior trees but not necessarily I

play07:01

mean you can not tie them but you would

play07:04

usually do that and you would store data

play07:08

there so blackboards do look like uh

play07:12

this so you just go to Blackboard and in

play07:15

Blackboard you have this you have keys

play07:18

and you can add more keys with I Vector

play07:23

key or maybe a a name key right you name

play07:27

all of that

play07:29

however you want and then in Blueprint

play07:32

you would just go uh yeah set

play07:37

Blackboard or maybe not like we probably

play07:40

need to get Blackboard first excuse mua

play07:44

for not being a pro at blackboards and

play07:46

behavior trees I kind of like didn't do

play07:49

much of AI before State trees so I

play07:51

didn't look at Behavior twist that much

play07:55

uh but you would get a Blackboard and

play07:57

then you can get value as class Bull

play08:01

inam Float in whatever

play08:03

or set value as float and da D and

play08:08

whenever you select that uh that node so

play08:12

set value as class or bull or whatever

play08:15

then you pass a key and that key

play08:19

corresponds to whatever is here so if we

play08:21

want to change that Vector key then we

play08:24

would pass you know a Lal name or

play08:27

whatever variable you want uh and then

play08:29

just type Vector key right and that

play08:32

Vector key well this doesn't make sense

play08:36

of course because you would want to set

play08:38

value as uh as Vector right and then

play08:42

just you know pass whatever Vector you

play08:45

want and uh all of that is stored in the

play08:50

in the Blackboard so how do we use

play08:53

blackboards with State trees I mean you

play08:56

kind of don't really but you still can

play09:00

and if you

play09:01

know uh I mean if you want to experiment

play09:04

and try anyway then go for it read that

play09:08

comment uh I think it's a great idea if

play09:12

you want to um work with

play09:15

blackboards and this guy used actually

play09:18

AI controller to hook State Tre to it to

play09:22

it and then kind of do a few more steps

play09:27

to uh to achieve that purpose

play09:29

and one thing new from State Tre 5.4 in

play09:34

the release version was actually a new

play09:37

schema so when we go to artificial

play09:40

intelligence state

play09:42

tree now in addition to state three

play09:45

component and probably game interaction

play09:49

yeah this is also a schema we have state

play09:51

three AI component and if we pick that

play09:54

AI component now we can make a different

play09:57

kind of state tree assets and those

play10:00

assets uh I already made one here it's

play10:04

this state AI component schema when we

play10:07

open this we have a controller class so

play10:12

this state tree asset is basically

play10:16

guaranteeing uh an access to AI

play10:19

controller class so probably what this

play10:22

guy did would be easier now with the 5.4

play10:25

release version because you know you

play10:27

have direct access to a controller and

play10:30

you can do more stuff uh so yeah that's

play10:33

the that's the third way you can uh

play10:36

store or manage data in in state

play10:39

trees and I guess one thing I wanted to

play10:43

show you is oh yeah this uh so

play10:46

description for State Tre II components

play10:49

is just it guarantees access to an i

play10:51

controller and the actual context value

play10:53

can be used to access the control P

play10:56

right so just you know expanded version

play10:58

of State Tre

play10:59

asset uh the uh normal asset we had at

play11:04

until this point right it's just you

play11:07

know we added one more variable

play11:11

um and this give me G gave me an idea

play11:16

like how else could we manage data and

play11:19

you know store some variables if we

play11:21

don't want to use a Blackboard and if we

play11:24

don't want to store variables straight

play11:27

in the actor and we don't really want to

play11:30

play with constructing a new object so I

play11:35

was thinking like hey okay we have a

play11:37

component uh State 3i component we have

play11:40

this you know uh a class AI controller

play11:43

class we can have context actor

play11:46

class and all of that is basically

play11:49

stored in a component we have to add

play11:52

anyway to you know um use stage tree

play11:57

with an actor and uh this guy so a

play12:01

Bernardo uh it works only with AI right

play12:06

so if we hook a Blackboard and we try to

play12:09

use the Blackboard with II controller

play12:11

then we kind of on we are only stuck

play12:15

with uh AI right and if we wanted to

play12:18

store or manage data in actors other

play12:22

than AI then you would need a different

play12:26

approach right and it's like no longer

play12:30

VI viable and you still could store data

play12:33

in the actor class and and do this

play12:36

approach but I think I have something

play12:39

better so uh my idea is to store data

play12:44

straight in that

play12:46

component right so just use it as a

play12:50

Blackboard and and the uh stage Tree in

play12:54

one component I mean it's uh probably uh

play12:59

controversial like you could disagree

play13:02

with me and say h we need to decouple

play13:05

the logic and the data read and you

play13:09

would be right in some way right but I

play13:13

don't necessarily like it and I think

play13:16

this uh way has its upsides so how do we

play13:21

store data in that component first of

play13:23

all when we make a state tree component

play13:28

right with with type state three like

play13:31

this and we also have state three II

play13:33

because I didn't tell you that but to

play13:36

use that new schema you have to use new

play13:38

component or it just doesn't show right

play13:41

we have I base follow R but we don't

play13:45

have um s AI base which is State Tre II

play13:50

component schema and we don't have of

play13:52

course this because it's gameplay

play13:54

interactions from uh my previous video

play13:58

so yeah you have to add a new type of

play14:02

component to use it and when you do add

play14:07

well any of that is basically this right

play14:10

you actually cannot get that asset you

play14:14

cannot set it and you cannot do anything

play14:17

meaningful to that because all of that

play14:20

is stuck with C++ and if you know me

play14:23

then you know uh I'm not a huge fan of

play14:25

C++ so I prefer to to do everything in

play14:31

uh in blueprints but sometimes C++ is

play14:34

inevitable so I went today to C++ and I

play14:39

made a new class because uh to actually

play14:43

expose what I want to expose to

play14:46

blueprints we have to do this in C++ so

play14:50

what did I do I made my own state three

play14:53

component and that state three component

play14:55

is actually exposed to a blueprint so

play15:00

yeah my idea is that we have a state Tre

play15:03

component and then we have variables

play15:06

that actually just store data and they

play15:08

are structured in a way that it's kind

play15:11

of similar to Blackboard so we have Maps

play15:14

uh we have like vector map we can do

play15:17

float map or we can do

play15:20

even uh make a separate object which is

play15:24

BP star and then just construct it when

play15:27

the uh state component is activated

play15:30

which is I mean if you want to do this

play15:33

uh this is just uh you know rumbling

play15:37

thinking loud kind of thing

play15:39

experimenting so there is a lot of way

play15:42

you can improve that system but yeah

play15:45

let's just do this right straight in the

play15:48

in the straight state tree component and

play15:50

see how this works so I added just a map

play15:54

Vector because I don't really want to

play15:56

add all of those things that are in the

play15:58

Black because yeah we just want to test

play16:01

it right see if that works um and how

play16:05

did I make that state Tre component

play16:09

because if you go to blueprint class and

play16:12

you type State

play16:14

Tre then uh this won't show all of that

play16:18

won't show and even if it does then you

play16:22

can't make a blueprint out of this but I

play16:25

made my own uh child class of State Rec

play16:28

compos component in C++ and then I made

play16:31

it blueprint so I made a state Tre

play16:35

component that is actually a blueprint

play16:38

and it's actually a super

play16:40

straightforward to uh to do you don't

play16:43

have to be a master at coding I'm just

play16:45

I'm just going to you know jump straight

play16:48

into the visual studio show you how to

play16:50

do this and how to actually expose some

play16:53

new functions that will or will not but

play16:56

probably will be useful to you in later

play16:59

date probably uh so let's jump into

play17:03

visual studio and this is how my project

play17:06

looks so we have that MRK state three

play17:10

component which you can see here or

play17:14

rather here because the that blueprint

play17:17

state three component is uh a child of

play17:19

am State Tre component and that is a

play17:23

custom C++ class I made here and that is

play17:27

of course uh in it from normal State Tre

play17:31

component and to actually compile it and

play17:35

use it don't forget to add very

play17:37

important modules uh which are

play17:42

um

play17:44

[Music]

play17:47

written here uh build find your build Cs

play17:51

and add those to modules otherwise yeah

play17:54

your project just won't compile and you

play17:58

will be stuck so uh I was actually stuck

play18:01

with this for a while because I the

play18:04

error messages are not very helpful

play18:07

sometimes but yeah you just need to add

play18:10

those modules and you are good to go and

play18:12

then what you want to do I just did it

play18:15

in that age but you can of course

play18:17

implement this in uh that CPP whatever

play18:22

you want and those two functions I added

play18:24

here uh is get State Tre asset and set

play18:28

state assets so now from blueprints we

play18:31

can just you know uh take that component

play18:35

we can now get it and get state three

play18:39

asset and now we can do something with

play18:41

it maybe we can uh kind of save it and

play18:44

we can of course set state tree

play18:48

asset and yeah just pick whatever you

play18:51

want so yeah very very very nice very

play18:56

cool and when you do that make sure to

play19:00

uh mark this class as blueprint

play19:03

and all of that I just copied from uh

play19:07

use stage three component so just you

play19:09

know copy this and paste and just add

play19:12

blueprint B so you can make a blueprint

play19:14

class out of that

play19:16

component and then those functions well

play19:19

I just made this pure and this is cable

play19:22

and you might wonder why this is get

play19:25

mutable State Tre uh it could probably

play19:28

work with just get state three but get

play19:31

state three returns a constant state Tre

play19:34

so You' have to add const here and

play19:38

maybe uh maybe it will have some

play19:42

problems later I don't know but mutable

play19:45

is just a straight pointer so I decided

play19:48

to H to go with this and this is all of

play19:51

the code right you just make a new C++

play19:54

function do do this right can zoom if

play19:58

you

play19:59

want rewrite it whatever and compile and

play20:03

you're good to go right and then you

play20:06

make a new blueprint class you write

play20:11

State

play20:12

Tre PB state three component select and

play20:16

you make your own component and now you

play20:17

can have variables in that component and

play20:20

whenever you want to store something you

play20:23

just go to uh whatever you can do this

play20:26

in STD as well so let's go to in it

play20:29

whatever and from Context class we can

play20:32

just get uh MRK or um how is it called

play20:38

BP State Tre

play20:43

component and

play20:46

uh State Tre component it was down here

play20:51

I don't know why didn't show before but

play20:54

okay we have that BP state three

play20:56

component and then we just take my M

play20:59

vector and we can store whatever vectors

play21:02

we want as keys and values in that map

play21:06

variable straightforward and simple to

play21:09

use and I think will be quite power

play21:12

powerful if you find a nice use for it

play21:15

so H what would be my use for it okay I

play21:19

hear you ask and very good question I'm

play21:23

going to I'm going to answer it right

play21:25

away because I have prepared an example

play21:28

for you guys and that example

play21:31

involves n nothing other than that map

play21:35

Vector so if you remember in our let's

play21:41

just maybe close all of that in our

play21:45

St base St AI base we have two states

play21:49

right we can roam we can follow all of

play21:52

that is dependent on the

play21:55

um on the bull variable that we have in

play22:01

or we should have in in BPI but now we

play22:05

don't for some reason I don't know why

play22:09

uh let's quickly maybe check yeah that

play22:12

actor follow kind of

play22:14

disappeared let's make it again follow

play22:18

and Mark it false we compile and yeah we

play22:22

are good kind of let's just reattach

play22:26

this where is the follow here

play22:29

okay follow follow and here it is good

play22:33

so in that uh AI base we just go to

play22:36

follow if the actor is going to be

play22:39

followed R if not and in AI Rome we have

play22:43

that St move to so um in my original

play22:49

example it was just 05 and it would also

play22:52

use as smart objects but for purpose of

play22:55

this video I just made it once so it is

play22:58

always picking that state and that state

play23:01

is using St move to which we will use

play23:05

for our example so what is the current

play23:10

purpose of the of that uh St move to

play23:15

well the purpose uh we want to um show

play23:20

today or experiment with is well we find

play23:24

a random position in the reachable

play23:28

radius or rather reachable point in

play23:32

radius and then we go to that point so

play23:36

that's the OG example and now with this

play23:40

um kind of you know data management we

play23:43

can save those locations sorry I'm kind

play23:46

of like um dry throat excuse

play23:53

M

play23:54

okay we can store those values and maybe

play23:58

[Music]

play24:00

be show a history of visited locations

play24:05

like this is probably something that

play24:07

could be useful in a real world scenario

play24:11

right so let's do this and in our St

play24:14

move

play24:15

to this is the the same code we uh we

play24:19

saw in the uh UE 5.4 preview updates

play24:25

video so you can just you know watch

play24:27

that but it's really not not complicated

play24:30

get H get the location select if random

play24:33

destination true then yeah get that and

play24:38

I am move to and then what we can do is

play24:41

just get that state three component take

play24:44

the map vector and add a value to that

play24:47

for key I'm just using time so this is

play24:51

BPU deals and it's using QTC now to make

play24:54

a basically unique key because I don't

play24:58

really need to name those uh values so

play25:01

it could just be an Ray instead but yeah

play25:06

we we are going with um with a map so I

play25:09

just made you know uh a key that is

play25:14

always unique so we add that position to

play25:18

a vector and then when we you know on

play25:23

success it's all on success then we got

play25:26

all of the keys and we look through

play25:28

through them and we make a draw debug

play25:31

line which takes one position and the

play25:35

next

play25:36

position and this is basically how you

play25:39

make a data history so now

play25:45

whenever the uh the character moves it

play25:49

stores a position in that map

play25:53

and when he gets to his location it just

play25:57

replay all of his visit locations and

play26:00

draws nice debu lines so yeah that's

play26:04

that's the example for these uh data

play26:07

management method and there are probably

play26:09

many more that you could do but this one

play26:13

I think is pretty pretty cool and will

play26:16

work with AI and non AI actors and you

play26:19

can just you

play26:21

know forget about initializing anything

play26:25

you can just you know add this and when

play26:28

whenever you want to store something

play26:29

then you just take that BP component

play26:32

store it in the map forget about it and

play26:34

it's all initialize it with uh the stage

play26:38

component so you don't have to remember

play26:41

about remember anything right just add

play26:44

stage you would normally add and it

play26:47

already comes with uh maps that you can

play26:51

use to start values so that's uh my

play26:54

little idea I hope you enjoy it and tell

play26:58

tell me what are

play27:00

your ideas on how to manage data in

play27:04

state

play27:05

trees so that's it uh drop a like drop a

play27:10

comment drop a sub of course most of you

play27:13

like 95% are not subbed and you should

play27:16

be subbed because I made uh Bunger

play27:19

videos like this one and see you next

play27:23

time bye-bye

Rate This

5.0 / 5 (0 votes)

関連タグ
Unreal EngineData ManagementState TreesAI ActorsGame DevelopmentBlueprintsC++Behavior TreesBlackboardsDebugging
英語で要約が必要ですか?