- Home /
Character AI in ScriptableObjects?
What is the best way to implement different schemas of character behaviors? I want my characters to follow a simple set of commands, like go to a position, do something there etc... Since I don't want to use Update methods for this, instead I would create a coroutine for each task and call one after another when it has finished running. Then I would create different scripts for different behaviors, to handle a combat behavior for example. The problem is, if I make this as MonoBehavior or just a simple script file, I haven't find a way to add an actual script to, let's say a character's "Array of behaviors" list, from where it could select a random one after spawning. Should I create each behavior file as ScriptableObject and handle them as Assets, or is there any better way to create this type of "tree of tasks" AI system? I hope someone can help me, I'm kinda noob at AI, thanks!
Answer by Daemonhahn · Nov 06, 2017 at 01:00 PM
Yes you can do AI in scriptable objects. You can have a main script that controls movement that you put on all agents, lets call this the "agent motor", and then a slot on that script that takes the scriptable object "brain". The scriptable object has a bunch of behaviours called "think", "act" etc that are common to all brains, but the code is different to give them different behaviours.
This tutorial shows this concept: https://www.youtube.com/watch?v=cHUXh5biQMg
Your answer
Follow this Question
Related Questions
AI Coroutine or ScriptableObject ? 1 Answer
Boxing character and AI enemys 2 Answers
Character Controller can pass through Collider 1 Answer
Update SetDestination only every 0.2s with coroutines ? 5 Answers
CoRoutine help 2 Answers