【Unity插件】Corgi Topdown Engine使用笔记

基本的角色Character

The best wayt to access the player(s) via script is via the LevelManager class,

// this will freeze your main character
LevelManager.Instance.Players[0].Freeze();

// sets the main character's max Health to 50
LevelManager.Instance.Players[0].gameObject.MMGetComponentNoAlloc<Health>().MaximumHealth = 50;

// forces the character to dash
LevelManager.Instance.Players[0].gameObject.MMGetComponentNoAlloc<CharacterDash>().StartDash();

Topdown Controller
Character组件作为一个中心点
Health组件来处理伤害问题
Character Abilities 最重要的来封装15种能力 (可选)

Standard Abilities

  • CharacterButtonActivation : This component allows your character to interact with button powered objects (dialogue zones, switches…). Nothing special to setup here. 按钮交互

  • CharacterConeOfVision : Projects a cone of vision around the character, that can be used to detect targets, or purely for decorative purposes. 侦查或装饰的光圈cone

  • CharacterCrouch : Allows for the resizing of the controller (and dedicated animations) when the crouch button is pressed 蹲下

  • CharacterDash2D/3D : This ability allows the character to dash in the specified direction. You can decide on a Dash Mode, specify a curve animation to use to move the character, the dash’s duration, the distance it should cover, and more. 冲刺

  • CharacterFallDownHoles2D : A 2D only ability, it will make your character fall down “holes”, defined by the hole layer mask you’ll have specified in the TopDownController2D’s inspector. 可跌落

  • CharacterGridMovement : lets you walk on a grid (meaning your character will always stop its movement perfectly centered on a grid’s cell). This works in both 2D and 3D and will **require that a GridManager be present and properly setup in your scene. **需要一个方格管理器 You’ll find examples of that setup in the Minimal2DGrid, Minimal3DGrid and Explodudes demo scenes. Note that this is a different system than the “regular” CharacterMovement, and most movement related abilities (jump, dash) or AI actions won’t work with grid movement. 总是会停在方格上,和其他的移动方式不兼容

  • CharacterHandleWeapon : Lets your character equip and use a weapon, whether it’s from an inventory or not. 装备和使用武器

  • CharacterHandleSecondaryWeapon : Same thing, but with one more weapon. 多一把武器

  • CharacterInventory : Lets your character bind itself to inventories, to be able to equip weapons and more. Note that the engine doesn’t support multiplayer inventories at the moment, but it’s been heavily requested and is coming to a future update. 可以装备和绑定

  • CharacterJump2D/3D : Will make your character jump when you press the jump button. Note that the 3D version will actually move your character’s controller, while the 2D version will keep it in place, an animation being responsible for the jump illusion. Note that in both cases, your character won’t be considered grounded anymore while jumping. 跳跃

  • CharacterMovement : Basic, ground based movement. You’ll be able to specify the walk speed, the idle threshold, acceleration and deceleration, footstep particles, and more from its inspector. You can also force free, 2, 4 or 8 directional movement. 角色移动

  • CharacterOrientation2D/3D : Will rotate or flip your character to have it face the movement’s direction, the weapon’s direction, or both. 带有方向的朝向

  • CharacterPathfinder3D : A 3D only ability, will let your character find a path on a navmesh. That navmesh will need to be present in the scene before it can be used though. 寻路3D

  • CharacterPause : Allows the character with this ability (and the player controlling it) to use the pause button to pause the game 可以暂停游戏的能力

  • CharacterRotation2D : Lets your 2D character change its model’s rotation to match the direction it’s going. 2d旋转和朝向

  • CharacterRun : Lets your character run at the specified speed when pressing the run button 按住奔跑键奔跑

  • CharacterSwap : This ability will allow you to swap control over multiple characters in a single scene. For an example of that, please refer to the Minimal2DCharacterSwap demo scene. Note that this ability is dependent on normal character instantiation by the LevelManager. 多角色切换控制

  • CharacterSwitchModel : Lets you switch the appearance of your character for another model. 切换角色的model

  • CharacterTimeControl : Lets your character change the current timescale to the one specified in the inspector when pressing the Time Control button, for the duration of your choice, lerping it or not. 可以在控制的时候修改timescale

  • Character Ability Node Swap : This ability lets you specify a new set of abilities, and swap to them at the press of a button. 修改技能设置

自己写技能可参见 https://topdown-engine-docs.moremountains.com/character-abilities.html#ability-overview

AI 部分

AIState : A State is a combination of one or more actions, and one or more transitions. An example of a state could be “patrolling until an enemy gets in range”. 不同action地组合
AIAction : Actions are behaviours and describe what your character is doing. Examples include patrolling, shooting, jumping, etc. The engine comes with a lot of predefined actions, and it’s very easy to create your own. 形容aciton是个什么东西
AIDecision : Decisions are components that will be evaluated by transitions, every frame, and will return true or false. Examples include time spent in a state, distance to a target, or object detection within an area. 判断是否需要过渡
AITransition : Transitions are a combination of one or more decisions and destination states whether or not these transitions are true or false. An example of a transition could be “if an enemy gets in range, transition to the Shooting state”. 包括了decisions条件以及目标状态
AIBrain : the AI brain is responsible for going from one state to the other based on the defined transitions. It’s basically just a collection of states, and it’s where you’ll link all the actions, decisions, states and transitions together. 将这些东西链接在一起

装备武器

需要有CharacterHandleWeapon的方法 -
Weapon Attachment

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,163评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,301评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,089评论 0 352
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,093评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,110评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,079评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,005评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,840评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,278评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,497评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,667评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,394评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,980评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,628评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,796评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,649评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,548评论 2 352

推荐阅读更多精彩内容