实例介绍
ReGoap是一个用C#编写的通用GOAP(目标导向行动规划)库,它附带了Unity3d的示例和辅助类。这个库非常通用,如果不包含Unity文件夹,你可以在任何游戏引擎中使用它。
GOAP(目标导向行动规划)是一种为游戏中的自主角色行为实时控制而特别设计的简化的STRIPS-like规划架构。它的基本功能是找到一系列行动(动作)计划,以实现所选择目标的目标。
要在Unity3D中使用ReGoap,首先克隆此仓库到Unity项目中。然后,为你的代理(Agent)创建一个GameObject,并添加ReGoapAgent组件,选择一个名称(你必须创建自己的类,继承ReGoapAgent或实现IReGoapAgent)。接着,添加ReGoapMemory组件,选择一个名称(你必须创建自己的类,继承ReGoapMemory或实现IReGoapMemory)。根据需要,重复添加你自己的感知器类,继承ReGoapSensor或实现IReGoapSensor。需要多次重复添加你自己的类,继承ReGoapAction或实现IReGoapAction,并通过覆盖Run函数来实现动作逻辑。
此外,你还需要添加你自己的类,继承ReGoapGoal或实现IReGoapGoal,并在任意GameObject上添加一个ReGoapPlannerManager(你必须创建自己的类,继承ReGoapPlannerManager),这将处理所有的规划。
【实例截图】
【核心代码】
文件清单
└── ReGoap-518b050eb920672bccb166c2678f26a534b4d32b
├── LICENSE
├── LICENSE.meta
├── ParseRaws.bat
├── ParseRaws.bat.meta
├── README.md
├── README.md.meta
├── ReGoap
│ ├── Core
│ │ ├── IReGoapAction.cs
│ │ ├── IReGoapAction.cs.meta
│ │ ├── IReGoapAgent.cs
│ │ ├── IReGoapAgent.cs.meta
│ │ ├── IReGoapAgentHelper.cs
│ │ ├── IReGoapAgentHelper.cs.meta
│ │ ├── IReGoapGoal.cs
│ │ ├── IReGoapGoal.cs.meta
│ │ ├── IReGoapMemory.cs
│ │ ├── IReGoapMemory.cs.meta
│ │ ├── IReGoapSensor.cs
│ │ ├── IReGoapSensor.cs.meta
│ │ ├── ReGoapActionState.cs
│ │ ├── ReGoapActionState.cs.meta
│ │ ├── ReGoapState.cs
│ │ └── ReGoapState.cs.meta
│ ├── Core.meta
│ ├── Planner
│ │ ├── AStar.cs
│ │ ├── AStar.cs.meta
│ │ ├── FastPriorityQueue.cs
│ │ ├── FastPriorityQueue.cs.meta
│ │ ├── IGoapPlanner.cs
│ │ ├── IGoapPlanner.cs.meta
│ │ ├── PlanDebugger.cs
│ │ ├── PlanDebugger.cs.meta
│ │ ├── PlanDebugger.tt
│ │ ├── PlanDebugger.tt.meta
│ │ ├── ReGoapNode.cs
│ │ ├── ReGoapNode.cs.meta
│ │ ├── ReGoapPlanner.cs
│ │ ├── ReGoapPlanner.cs.meta
│ │ ├── ReGoapPlannerSettings.cs
│ │ └── ReGoapPlannerSettings.cs.meta
│ ├── Planner.meta
│ ├── Unity
│ │ ├── Editor
│ │ │ ├── ReGoapNodeBaseEditor.cs
│ │ │ ├── ReGoapNodeBaseEditor.cs.meta
│ │ │ ├── ReGoapNodeEditor.cs
│ │ │ ├── ReGoapNodeEditor.cs.meta
│ │ │ ├── Test
│ │ │ │ ├── ReGoapBenchmarkTests.cs
│ │ │ │ ├── ReGoapBenchmarkTests.cs.meta
│ │ │ │ ├── ReGoapTests.cs
│ │ │ │ ├── ReGoapTests.cs.meta
│ │ │ │ ├── ReGoapTestsHelper.cs
│ │ │ │ └── ReGoapTestsHelper.cs.meta
│ │ │ └── Test.meta
│ │ ├── Editor.meta
│ │ ├── FSM
│ │ │ ├── ISMState.cs
│ │ │ ├── ISMState.cs.meta
│ │ │ ├── SmState.cs
│ │ │ ├── SmState.cs.meta
│ │ │ ├── StateMachine.cs
│ │ │ └── StateMachine.cs.meta
│ │ ├── FSMExample
│ │ │ ├── Actions
│ │ │ │ ├── AddResourceToBankAction.cs
│ │ │ │ ├── AddResourceToBankAction.cs.meta
│ │ │ │ ├── CraftRecipeAction.cs
│ │ │ │ ├── CraftRecipeAction.cs.meta
│ │ │ │ ├── GatherResourceAction.cs
│ │ │ │ ├── GatherResourceAction.cs.meta
│ │ │ │ ├── GenericGoToAction.cs
│ │ │ │ └── GenericGoToAction.cs.meta
│ │ │ ├── Actions.meta
│ │ │ ├── Agents
│ │ │ │ ├── BuilderAgent.cs
│ │ │ │ └── BuilderAgent.cs.meta
│ │ │ ├── Agents.meta
│ │ │ ├── BuilderAgent.prefab
│ │ │ ├── BuilderAgent.prefab.meta
│ │ │ ├── ExampleFSMScene.unity
│ │ │ ├── ExampleFSMScene.unity.meta
│ │ │ ├── FSM
│ │ │ │ ├── SmsGoTo.cs
│ │ │ │ ├── SmsGoTo.cs.meta
│ │ │ │ ├── SmsIdle.cs
│ │ │ │ └── SmsIdle.cs.meta
│ │ │ ├── FSM.meta
│ │ │ ├── Goals
│ │ │ │ ├── CollectResourceGoal.cs
│ │ │ │ └── CollectResourceGoal.cs.meta
│ │ │ ├── Goals.meta
│ │ │ ├── Memories
│ │ │ │ ├── BuilderMemory.cs
│ │ │ │ └── BuilderMemory.cs.meta
│ │ │ ├── Memories.meta
│ │ │ ├── OtherScripts
│ │ │ │ ├── AgentsSpawner.cs
│ │ │ │ ├── AgentsSpawner.cs.meta
│ │ │ │ ├── AxeRecipe.asset
│ │ │ │ ├── AxeRecipe.asset.meta
│ │ │ │ ├── Bank.cs
│ │ │ │ ├── Bank.cs.meta
│ │ │ │ ├── BankDebugToText.cs
│ │ │ │ ├── BankDebugToText.cs.meta
│ │ │ │ ├── BankManager.cs
│ │ │ │ ├── BankManager.cs.meta
│ │ │ │ ├── MultipleResourcesManager.cs
│ │ │ │ ├── MultipleResourcesManager.cs.meta
│ │ │ │ ├── PrimitiveResource.cs
│ │ │ │ ├── PrimitiveResource.cs.meta
│ │ │ │ ├── Recipe.cs
│ │ │ │ ├── Recipe.cs.meta
│ │ │ │ ├── Resource.cs
│ │ │ │ ├── Resource.cs.meta
│ │ │ │ ├── ResourceManager.cs
│ │ │ │ ├── ResourceManager.cs.meta
│ │ │ │ ├── ResourcesBag.cs
│ │ │ │ ├── ResourcesBag.cs.meta
│ │ │ │ ├── Utilities.cs
│ │ │ │ ├── Utilities.cs.meta
│ │ │ │ ├── WoodRecipe.asset
│ │ │ │ ├── WoodRecipe.asset.meta
│ │ │ │ ├── Workstation.cs
│ │ │ │ ├── Workstation.cs.meta
│ │ │ │ ├── WorkstationsManager.cs
│ │ │ │ └── WorkstationsManager.cs.meta
│ │ │ ├── OtherScripts.meta
│ │ │ ├── Planners
│ │ │ │ ├── FSMExamplePlannerManager.cs
│ │ │ │ └── FSMExamplePlannerManager.cs.meta
│ │ │ ├── Planners.meta
│ │ │ ├── Sensors
│ │ │ │ ├── BankSensor.cs
│ │ │ │ ├── BankSensor.cs.meta
│ │ │ │ ├── MultipleResourcesSensor.cs
│ │ │ │ ├── MultipleResourcesSensor.cs.meta
│ │ │ │ ├── PositionSensor.cs
│ │ │ │ ├── PositionSensor.cs.meta
│ │ │ │ ├── ResourcesBagSensor.cs
│ │ │ │ ├── ResourcesBagSensor.cs.meta
│ │ │ │ ├── ResourceSensor.cs
│ │ │ │ ├── ResourceSensor.cs.meta
│ │ │ │ ├── WorkstationSensor.cs
│ │ │ │ └── WorkstationSensor.cs.meta
│ │ │ ├── Sensors.meta
│ │ │ ├── UnityObjects
│ │ │ │ ├── Materials
│ │ │ │ │ ├── BankMaterial.mat
│ │ │ │ │ ├── BankMaterial.mat.meta
│ │ │ │ │ ├── ManualLaborMaterial.mat
│ │ │ │ │ ├── ManualLaborMaterial.mat.meta
│ │ │ │ │ ├── OreMaterial.mat
│ │ │ │ │ ├── OreMaterial.mat.meta
│ │ │ │ │ ├── TreeMaterial.mat
│ │ │ │ │ ├── TreeMaterial.mat.meta
│ │ │ │ │ ├── WorkstationMaterial.mat
│ │ │ │ │ └── WorkstationMaterial.mat.meta
│ │ │ │ └── Materials.meta
│ │ │ └── UnityObjects.meta
│ │ ├── FSMExample.meta
│ │ ├── FSM.meta
│ │ ├── ReGoapAction.cs
│ │ ├── ReGoapAction.cs.meta
│ │ ├── ReGoapAgentAdvanced.cs
│ │ ├── ReGoapAgentAdvanced.cs.meta
│ │ ├── ReGoapAgent.cs
│ │ ├── ReGoapAgent.cs.meta
│ │ ├── ReGoapGoalAdvanced.cs
│ │ ├── ReGoapGoalAdvanced.cs.meta
│ │ ├── ReGoapGoal.cs
│ │ ├── ReGoapGoal.cs.meta
│ │ ├── ReGoapMemoryAdvanced.cs
│ │ ├── ReGoapMemoryAdvanced.cs.meta
│ │ ├── ReGoapMemory.cs
│ │ ├── ReGoapMemory.cs.meta
│ │ ├── ReGoapPlannerManager.cs
│ │ ├── ReGoapPlannerManager.cs.meta
│ │ ├── ReGoapSensor.cs
│ │ ├── ReGoapSensor.cs.meta
│ │ ├── Test
│ │ │ ├── ReGoapTestAction.cs
│ │ │ ├── ReGoapTestAction.cs.meta
│ │ │ ├── ReGoapTestAgent.cs
│ │ │ ├── ReGoapTestAgent.cs.meta
│ │ │ ├── ReGoapTestGoal.cs
│ │ │ ├── ReGoapTestGoal.cs.meta
│ │ │ ├── ReGoapTestMemory.cs
│ │ │ └── ReGoapTestMemory.cs.meta
│ │ └── Test.meta
│ ├── Unity.meta
│ ├── Utilities
│ │ ├── ReGoapLogger.cs
│ │ └── ReGoapLogger.cs.meta
│ └── Utilities.meta
└── ReGoap.meta
21 directories, 178 files
标签:
小贴士
感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。
- 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
- 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
- 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
- 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。
关于好例子网
本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明
网友评论
我要评论