基本的角色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組件作為一個(gè)中心點(diǎn)
Health組件來(lái)處理傷害問(wèn)題
Character Abilities 最重要的來(lái)封裝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. **需要一個(gè)方格管理器 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. 總是會(huì)停在方格上革砸,和其他的移動(dòng)方式不兼容
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. 角色移動(dòng)
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旋轉(zhuǎn)和朝向
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. 可以在控制的時(shí)候修改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. 修改技能設(shè)置
自己寫(xiě)技能可參見(jiàn) 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是個(gè)什么東西
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. 判斷是否需要過(guò)渡
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條件以及目標(biāo)狀態(tài)
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