Very usefull, a nice introduction to state tree and simple NPC Movements. I'm starting to implement IA for my game and it was one of the most useful tutorial I found to kickstart it.
I really hope you make more content around state tress this has been an amazing help for me. What is the best way to interrupt a state? the AI Move to or Move to Location or Actor will pause the task in the tree until the move is completed. This means say I have an enemy AI that moves to location, but upon his AI perception detecting my actor via sight i'd like them to stop moving and say move into the nearest cover and kick off a different set of actions. The only way I've found is to have the movement state wire up a hook into the AI Perception events and look for those AI perception events and then cancel the movement, which would fail the task and then the task would proceed down the tree, but I don't have a good way of saying. "no stop movement, you need to move into the attack state now"
Thank you! :D This is an interesting one. You could call Restart on the state tree which would stop the tasks and make the tree go back to the base. Another option is to try out the global tasks on the state tree. I'm not sure if a global task completing with a transistion to another state would cancel the other states or not (I'll have to test this) The other option, is to reduce the tick amount in class settings, and on your move to task, it checks if it needs to be interrupted :)
Hi do you know how to spawn and despawn NPC but simulate their task, health/status and even do combat on the backend even though the player is not around in the area. Give NPC's some form of persistence. I've been looking for some sort of tutorial like this but I can't seem to find anything about it online. I would like to know where to start in designing something like this in UE5.
Hey! Its an interesting question. I think you'd have to really think how much you want to be done. If you are having a hidden non rendered npc doing 100% of the work they'd do if you were right next to them, you might want to rethink the idea. Why are they doing the exact same task with you not in the same region? Do they NEED to do the tasks physically or can it be simulated? For instance, if were are talking something like an NPC farming. They need to farm whether you are there or not. When they are hidden / you are far enough away. Stop their AI logic / hide the etc.. Then note down the current game time from the point they stopped renderering. Now you have a fixed point in time from when they stopped. When you go back in and they start renderering, you can hook into world parition to see when they came back online then check that last saved date. Work out how long it takes them to perform their farming action then muliply it based on the save time and the new current time. E.g. 3 minutes they've been out of action. Every 10 seconds they can farm 10 items. 180 (3 minutes in seconds) / 10 - 18 * 10 then you can artifically apply the updates making it LOOK like they kept working. Super optimised :)
Hey! Depending how you create your state tree tasks (such as how you move your AI) you may have to create a navmesh yes. If you use Unreal's default AI stuff, then you will need it. If you use another plugin, it might not use it :)
@@D3kryption I’m just now trying to make a crowd, like L4D or Days Gone, but the usual crowd AI loads the system a lot. And I’m thinking of implementing this using mass AI, but I don’t know if it needs navmesh
@@CGPine I believe MassAI doesn't by default use the navigation system and simply simulates walking between multiple points. I found this link which claims to have done it but I've not tested it :D github.com/stopthem/MassZombies
What do you think of StateTrees vs Behavour Trees then? Have you used any? Which do you prefer? Let me know below! :)
State tree all the way
Omg. Yes!
Thank you so much for this one! Really wanna get into State Trees but couldn't find one concise enough.
Happy I could help! :D
Very usefull, a nice introduction to state tree and simple NPC Movements. I'm starting to implement IA for my game and it was one of the most useful tutorial I found to kickstart it.
I really love the state trees. They just need some more TLC from epic :D
I really hope you make more content around state tress this has been an amazing help for me. What is the best way to interrupt a state? the AI Move to or Move to Location or Actor will pause the task in the tree until the move is completed. This means say I have an enemy AI that moves to location, but upon his AI perception detecting my actor via sight i'd like them to stop moving and say move into the nearest cover and kick off a different set of actions. The only way I've found is to have the movement state wire up a hook into the AI Perception events and look for those AI perception events and then cancel the movement, which would fail the task and then the task would proceed down the tree, but I don't have a good way of saying. "no stop movement, you need to move into the attack state now"
Thank you! :D
This is an interesting one. You could call Restart on the state tree which would stop the tasks and make the tree go back to the base.
Another option is to try out the global tasks on the state tree.
I'm not sure if a global task completing with a transistion to another state would cancel the other states or not (I'll have to test this)
The other option, is to reduce the tick amount in class settings, and on your move to task, it checks if it needs to be interrupted :)
Nice video ! Have you done a quest board using narrative? Where quests have cooldown!
I've got this one noted down! Its a great idea :D
Hi do you know how to spawn and despawn NPC but simulate their task, health/status and even do combat on the backend even though the player is not around in the area. Give NPC's some form of persistence. I've been looking for some sort of tutorial like this but I can't seem to find anything about it online. I would like to know where to start in designing something like this in UE5.
Hey!
Its an interesting question.
I think you'd have to really think how much you want to be done.
If you are having a hidden non rendered npc doing 100% of the work they'd do if you were right next to them, you might want to rethink the idea. Why are they doing the exact same task with you not in the same region? Do they NEED to do the tasks physically or can it be simulated?
For instance, if were are talking something like an NPC farming. They need to farm whether you are there or not.
When they are hidden / you are far enough away. Stop their AI logic / hide the etc..
Then note down the current game time from the point they stopped renderering.
Now you have a fixed point in time from when they stopped.
When you go back in and they start renderering, you can hook into world parition to see when they came back online
then check that last saved date.
Work out how long it takes them to perform their farming action then muliply it based on the save time and the new current time.
E.g. 3 minutes they've been out of action. Every 10 seconds they can farm 10 items.
180 (3 minutes in seconds) / 10 - 18 * 10
then you can artifically apply the updates making it LOOK like they kept working.
Super optimised :)
I dont got it if we can just use state tree on ai controller then why its not working untless i add it to the character blueprint
Have you assigned your character blueprint the correct AI controller?
@@D3kryption yess i did and also the state tree don't have any decorator type function something to abort a task on the value changes
Hi. I have a question. StateTree AI needs a navmesh?
Hey!
Depending how you create your state tree tasks (such as how you move your AI) you may have to create a navmesh yes.
If you use Unreal's default AI stuff, then you will need it.
If you use another plugin, it might not use it :)
@@D3kryption I’m just now trying to make a crowd, like L4D or Days Gone, but the usual crowd AI loads the system a lot. And I’m thinking of implementing this using mass AI, but I don’t know if it needs navmesh
@@CGPine I believe MassAI doesn't by default use the navigation system and simply simulates walking between multiple points.
I found this link which claims to have done it but I've not tested it :D
github.com/stopthem/MassZombies
@@D3kryption thanks