en:toolworks:docs:apparatus:beginner

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Last revisionBoth sides next revision
en:toolworks:docs:apparatus:beginner [2021/12/04 23:04] – [Conclusion] vladiusen:toolworks:docs:apparatus:beginner [2022/01/04 19:06] – синхронизированно с русской версией jispar
Line 8: Line 8:
  
    - Before creating a new project, you have to add the Apparatus plugin to the Engine. In order to do that, please, launch the 'Epic Game Launcher' and make sure that the 'Unreal Engine' item is currently active in the left-most menu. Then, navigate to the 'Library' tab on top. Scroll down to the 'Vault' section to find the Apparatus plugin along with a yellow button titled 'Install to Engine'. Press that button to proceed installing.{{ :en:toolworks:docs:apparatus-add-to-engine.png?nolink |}}    - Before creating a new project, you have to add the Apparatus plugin to the Engine. In order to do that, please, launch the 'Epic Game Launcher' and make sure that the 'Unreal Engine' item is currently active in the left-most menu. Then, navigate to the 'Library' tab on top. Scroll down to the 'Vault' section to find the Apparatus plugin along with a yellow button titled 'Install to Engine'. Press that button to proceed installing.{{ :en:toolworks:docs:apparatus-add-to-engine.png?nolink |}}
- +   - In the opened section choose the version of Unreal Engine. Note that officially supported versions for now are 4.26.1 or above. After clicking 'Install' wait for a minute while the launcher loads the necessary files to the engine. When the installation has completed, you can verify its success by clicking the 'Installed Plugins' footer under Unreal Engine version you have installed the plugin for.{{ :en:toolworks:docs:apparatus-check-installation.png?nolink |}}
-   - In the opened section choose the version of Unreal Engine. Note that you should use 4.26.1 (or above) as it's the only officially supported for now. After clicking 'Install' wait for a minute while the launcher loads the necessary files to the engine. When the installation has completed, you can verify its success by clicking the 'Installed Plugins' footer under Unreal Engine version you have installed the plugin for.{{ :en:toolworks:docs:apparatus-check-installation.png?nolink |}}+
  
 ==== Project Creation & Initialization ==== ==== Project Creation & Initialization ====
Line 23: Line 22:
       * 'JumpMoveInput' – keyboard key <key>w</key>       * 'JumpMoveInput' – keyboard key <key>w</key>
    - The result must be something like that: {{ :en:toolworks:docs:apparatus-bindings.png?nolink |}}    - The result must be something like that: {{ :en:toolworks:docs:apparatus-bindings.png?nolink |}}
-   - We proceed with creating a new Pawn Blueprint. In order to do that click green button 'Add/Import' in the 'Content Browser' and select 'Blueprint Class'->'Pawn' and give it a name 'BP_MainPawn' (for a sane naming convention practices, please, check this [[https://github.com/Allar/ue4-style-guide|style guide]]). While selecting the Blueprint in the 'Content Browser' press <key>Ctrl</key>+<key>s</key> to save the newly created item. Now open it by double-clicking on its thumbnail (if you are really new to Content Browser, we're advising you to read the [[ue>Basics/ContentBrowser/index.html|official Manual]]). Navigate to 'Event-graph' and delete all the nodes by <key>Ctrl</key>+<key>a</key> and <key>Del</key>. You should also understand how to use [[ue>ProgrammingAndScripting/Blueprints/Editor/index.html|Blueprint Editor]]; hereinafter BP)+   - We proceed with creating a new Pawn Blueprint. In order to do that click green button 'Add/Import' in the 'Content Browser' and select 'Blueprint Class'->'Pawn' and give it a name 'BP_MainPawn' (for a sane naming convention practices, please, check this [[https://github.com/Allar/ue4-style-guide|style guide]]). While selecting the Blueprint in the 'Content Browser' press <key>Ctrl</key>+<key>s</key> to save the newly created item. Now open it by double-clicking on its thumbnail (if you are really new to Content Browser, we're advising you to read the [[ue>Basics/ContentBrowser/index.html|official Manual]]). Navigate to 'Event-graph' and delete all the nodes by <key>Ctrl</key>+<key>a</key> and <key>Del</key>. You should also understand how to use [[ue>ProgrammingAndScripting/Blueprints/Editor/index.html|Blueprint Editor]]; hereinafter BP. 
-   - In the BP Editor switch to Viewport and in the [[ue>Basics/Components|'Components']] section add a 'StaticMesh'. In the [[ue>ProgrammingAndScripting/Blueprints/Editor/UIComponents/Details|'Details' panel]] on the right pick the 'Cube' model for the 'Static Mesh' property. For our pawn to look even prettier, choose the 'BrushedMetal' material as the 'Element 0' property value. Add a 'Subjective Actor' component (this is actually provided by the Apparatus plugin) to your Pawn and look into the Details Panel to become more familiar with the new Actor Component. During this guide we will only use the properties under the 'Details' section:{{ :en:toolworks:docs:apparatus-details-panel.png?nolink |}} As you may have already understood, we will add our own details in there.+   - In the BP Editor switch to Viewport and in the [[ue>Basics/Components|'Components']] section add a 'StaticMesh'. In the [[ue>ProgrammingAndScripting/Blueprints/Editor/UIComponents/Details|'Details' panel]] on the right pick the 'Cube' model for the 'Static Mesh' property. For our pawn to look even prettier, choose the 'BrushedMetal' material as the 'Element 0' property value. Add a **'Subjective Actor'** component (this is actually provided by the Apparatus plugin) to your Pawn and look into the Details Panel to become more familiar with the new Actor Component. During this guide we will only use the properties under the 'Details' section:{{ :en:toolworks:docs:apparatus-details-panel.png?nolink |}} As you may have already understood, we will add our own details in there.
    - <key>Ctrl</key>+<key>Shift</key>+<key>s</key> to save everything, and compile the BP. Once again open the Content Browser and start creating a new BP, but this time you should expand the 'All Classes' pane and find the 'Detail' class type there:{{ :en:toolworks:docs:apparatus-new-detail.png?nolink |}} You can also use the Create Advanced Asset section of the Content Browser's context menu (accessed using the right-mouse-button): {{ :en:toolworks:docs:apparatus:extra-detail-creation.png?nolink |}}    - <key>Ctrl</key>+<key>Shift</key>+<key>s</key> to save everything, and compile the BP. Once again open the Content Browser and start creating a new BP, but this time you should expand the 'All Classes' pane and find the 'Detail' class type there:{{ :en:toolworks:docs:apparatus-new-detail.png?nolink |}} You can also use the Create Advanced Asset section of the Content Browser's context menu (accessed using the right-mouse-button): {{ :en:toolworks:docs:apparatus:extra-detail-creation.png?nolink |}}
    - Generally speaking, you can and should create as many details as you want, but for the tutorial sake we need specifically the following:    - Generally speaking, you can and should create as many details as you want, but for the tutorial sake we need specifically the following:
Line 34: Line 33:
       * Float 'Speed' to the ''D_Moveable'' class with a default value of ''100.0''.       * Float 'Speed' to the ''D_Moveable'' class with a default value of ''100.0''.
       * Editable enum ''ETouch Swipe Direction'' named ''Direction'' to the ''D_Moving'' class.       * Editable enum ''ETouch Swipe Direction'' named ''Direction'' to the ''D_Moving'' class.
-      * Editable & exposed on spawn Box Collision Object Reference named 'Bottom' to the ''D_Fallable'' class.{{ :en:toolworks:docs:apparatus:apparatus-many-ddd.png?nolink |}} +      * Editable & exposed on spawn ''Box Collision Object Reference'' named 'Bottom' to the ''D_Fallable'' class.{{ :en:toolworks:docs:apparatus:apparatus-many-ddd.png?nolink |}} 
-   - Go back to the 'BP_MainPawn' blueprint and make the cube a little smaller (say, ''(0.25, 0.25, 0.25)'' on a vector scale). Add a 'Spring Arm' component to the 'DefaultSceneRoot' and the Camera to the arm (make sure that transform vectors are set to their default values); then rotate the arm over the Z-axis by 180° and after that rotate it over the Y-axis by -30°.+   - Go back to the 'BP_MainPawn' blueprint and make the cube a little smaller (for examplecopy the string ''(0.25, 0.25, 0.25)'' with parentheses and paste into the scale vector with right mouse button click; if all's right you'll get corresponding values in the vector). Add a 'Spring Arm' component to the 'DefaultSceneRoot' and the Camera to the arm (make sure that transform vectors are set to their default values); then rotate the arm over the Z-axis by 180° and after that rotate it over the Y-axis by -30°.
    - In the result you should get something like that: {{ :en:toolworks:docs:apparatus-set-camera.png?nolink |}}    - In the result you should get something like that: {{ :en:toolworks:docs:apparatus-set-camera.png?nolink |}}
-   - Create a 'GameMode' (or a 'GameModeBase') class inherited from 'MechanicalGameMode' (or 'MechanicalGameModeBase') and name it something like 'BP_Mechanism'. Like so:{{ :en:toolworks:docs:apparatus-create-mechanism.png?nolink |}}+   - Create a 'GameMode' (or a 'GameModeBase', - both variants are possible) class inherited from 'MechanicalGameMode' (or 'MechanicalGameModeBase') and name it something like 'BP_Mechanism'. Like so:{{ :en:toolworks:docs:apparatus-create-mechanism.png?nolink |}}
    - Open 'BP_Mechanism' in the Blueprint Editor and in the Details Panel set the 'Default pawn class' value to 'BP_MainPawn'. Go to the level settings: 'Blueprints'->'Project Settings : GameMode' and select 'BP_Mechanism' as the project's main 'GameMode' class:{{ :en:toolworks:docs:apparatus-select-gamemode.png?nolink |}}    - Open 'BP_Mechanism' in the Blueprint Editor and in the Details Panel set the 'Default pawn class' value to 'BP_MainPawn'. Go to the level settings: 'Blueprints'->'Project Settings : GameMode' and select 'BP_Mechanism' as the project's main 'GameMode' class:{{ :en:toolworks:docs:apparatus-select-gamemode.png?nolink |}}
    - Now, if you run the game, you will notice that the camera is actually working, but the cube won't move while pressing the aforementioned <key>a</key>, <key>d</key>, <key>w</key> keys. Let's fix this. First, jump to 'BP_MainPawn' and in the components list select the 'SubjectiveActor' component to see its properties in the Details Panel. For the 'Details' property add a new detail by clicking on the ''+'' button and selecting the detail class. Add exactly two details like on the following shot:{{ :en:toolworks:docs:apparatus-details-list.png?nolink |}}    - Now, if you run the game, you will notice that the camera is actually working, but the cube won't move while pressing the aforementioned <key>a</key>, <key>d</key>, <key>w</key> keys. Let's fix this. First, jump to 'BP_MainPawn' and in the components list select the 'SubjectiveActor' component to see its properties in the Details Panel. For the 'Details' property add a new detail by clicking on the ''+'' button and selecting the detail class. Add exactly two details like on the following shot:{{ :en:toolworks:docs:apparatus-details-list.png?nolink |}}
    - As you see, you can easily add or remove details from the 'BP_MainPawn' actor component; it doesn't actually matter how they are exactly ordered. You're also able to see the variables of the details and change their default values. Note that if you change the value of the 'Speed' in the list, for example, it won't be changed in the 'BP_Moveable' class itself, because here in the list the instances of the detail classes are presented while in the Blueprint Editor of the 'BP_Moveable' class you can change the global default values for its properties. Change the speed right here in the list to 500.    - As you see, you can easily add or remove details from the 'BP_MainPawn' actor component; it doesn't actually matter how they are exactly ordered. You're also able to see the variables of the details and change their default values. Note that if you change the value of the 'Speed' in the list, for example, it won't be changed in the 'BP_Moveable' class itself, because here in the list the instances of the detail classes are presented while in the Blueprint Editor of the 'BP_Moveable' class you can change the global default values for its properties. Change the speed right here in the list to 500.
-   - It's better to do so in Controller but for brevity let's do it here. Being in the BP Editor of the 'BP_MainPawn' navigate to 'Event Graph' and add our 3 input events we have declared previously (see **step 2 of Implementation**). Create the node 'Get SubjectiveActor', drag from it 3 new nodes, which are 'Add detail' and in the Detail Type field choose 'D_Moving'. After that you can see the returning type of each node currently is 'D Moving Object Reference'. I.e. after the detail was added you can 'promote it to variable' and call functions from it or access variables. In our case we will change the Direction variable to corresponding value. **Don't forget** to pin all of the Reuse Disabled checkboxes (We will talk later why you should do so).  The whole scheme now should look like so:{{ :en:toolworks:docs:apparatus-move-input.png?nolink |}}+   - It's better to do so in Controller but for brevity let's do it here. Being in the BP Editor of the 'BP_MainPawn' navigate to 'Event Graph' and add our 3 input events we have declared previously (see **step 2 of Implementation**). Create the node 'Get SubjectiveActor', drag from it 3 new nodes, which are 'Add detail' and in the Detail Type field choose 'D_Moving'. After that you can see the returning type of each node currently is ''D Moving Object Reference''. I.e. after the detail was added you can 'promote it to variable' and call functions from it or access variables. In our case we will change the Direction variable to corresponding value. **Don't forget** to pin all of the Reuse Disabled checkboxes (We will talk later why you should do so).  The whole scheme now should look like so:{{ :en:toolworks:docs:apparatus-move-input.png?nolink |}}
    - All we have to to do now is to implement the game mechanics in our GameMode. So open the BP Editor once again for the 'BP_Mechanism' and in the Graph view, delete all of the nodes except for the 'Event Tick' node. Promote the ''Delta Seconds'' value to a global ''GlobalDelta'' variable mainly for convenience purposes. Now we need to iterate over all of the subjects and for each of them, check if it complies with our special case. So, for that drag the next node - 'Sequence', and from its first output drag the filament link and find the 'Mechanic' node.{{ :en:toolworks:docs:apparatus-evaluate.png?nolink |}}    - All we have to to do now is to implement the game mechanics in our GameMode. So open the BP Editor once again for the 'BP_Mechanism' and in the Graph view, delete all of the nodes except for the 'Event Tick' node. Promote the ''Delta Seconds'' value to a global ''GlobalDelta'' variable mainly for convenience purposes. Now we need to iterate over all of the subjects and for each of them, check if it complies with our special case. So, for that drag the next node - 'Sequence', and from its first output drag the filament link and find the 'Mechanic' node.{{ :en:toolworks:docs:apparatus-evaluate.png?nolink |}}
-   - As you see, 'Mechanic' gets a 'Mechanical Interface' as its input 'self', which is in fact our 'BP_Mechanism' is. This node will iterate over all of the entities (subjects) with a specific set of details enabled/disabled. As how it is from the starts, essentially all of the subjects which will comply with the empty requirements. 'Evaluation Body' pin gets executed for each complying subject. After all of complying subjects were processed, the 'Completed' pin gets executed. RMB-click on the node and in the opened context menu you will see two last items with these titles: 'Add Detail Pin' and 'Add Excluded Detail Pin'. You can click these items several times and see that each time you do so, a new pin with a dot or exclamation mark is added to the node. By using this workflow and selecting the detail types in the added inputs you declare an evaluation filter, for the subjects to be processed in the mechanic. {{ :en:toolworks:docs:apparatus-evaluate-full.png?nolink |}} For example, add two including "dot"-pins to the node and delete all of the others (by RMB-clicking on them and selecting the 'Remove Detail Pin' option). Choose their types as Moveable and Moving. Promote the 'Moving' detail to a 'TempMoving' variable - or you'll get yourself too much "noodles". From the 'Subjective' output pin drag a 'Get Actor' pure function. That is also provided by Apparatus and returns the actor that is currently being processed. From this function's output drag a 'AddActorLocalOffset' node. From the 'D_Moving' pin drag the 'Direction' variable and make 'Select' block to easily choose the corresponding vector depending on the direction currently active in the detail. 'Left and 'Right' cases are split into components and fill the Y-component of the left-side case with the 'Speed' variable obtained from the 'Moveable' detail and multiplicated by the 'GlobalDelta' variable. For the right-side case use the same value just with an opposite sign. Below your 'AddActorLocalOffset' node place the deactivation of the 'TempMoving' detail be setting its state 'Enabled' to false. After all the above actions you should have something like that:{{ :en:toolworks:docs:apparatus-mechanism-moving-logic.png?nolink |}}What's actually going on here? As you may remember, we defined how we determine our keyboard input at some previous step. Here we just move each actor with the pointed details over their local Y-axis (for the camera view, it's actually moving to the left if Y-axis is > 0 and moving to the right otherwise). So, depending on the direction we obtained from the 'Moving' detail we move an actor across the scene. After doing so, we disable the Moving detail, so it won't be moving to the side anymore. Good. But what will happen when the player presses a <key>d</key> or a <key>a</key> key a second time? Do you remember the checkbox we pinned? The 'Reuse Disabled' in fact means that if the 'Subjective' has a disabled detail then the function will enable it and return as its output instead of creating a new one. So now you can run the game and check if it works. Use <key>a</key> & <key>d</key> keys to move the box around.+   - As you see, 'Mechanic' gets a 'Mechanical Interface' as its input 'self', which is in fact our 'BP_Mechanism' is. This node will iterate over all of the entities (subjects) with a specific set of details enabled/disabled. As how it is from the starts, essentially all of the subjects which will comply with the empty requirements. 'Evaluation Body' pin gets executed for each complying subject. After all of complying subjects were processed, the 'Completed' pin gets executed. RMB-click on the node and in the opened context menu you will see two last items with these titles: 'Add Detail Pin' and 'Add Excluded Detail Pin'. You can click these items several times and see that each time you do so, a new pin with a dot or exclamation mark is added to the node. By using this workflow and selecting the detail types in the added inputs you declare an evaluation filter, for the subjects to be processed in the mechanic. {{ :en:toolworks:docs:apparatus-evaluate-full.png?nolink |}} For example, add two including "dot"-pins to the node and delete all of the others (by RMB-clicking on them and selecting the 'Remove Detail Pin' option). Choose their types as ''D_Moveable'' and ''D_Moving''. Promote the ''Moving'' detail to a ''TempMoving'' variable - or you'll get yourself too much "noodles". From the 'Subjective' output pin drag a 'Get Actor' pure function. That is also provided by Apparatus and returns the actor that is currently being processed. From this function's output drag a 'AddActorLocalOffset' node. From the ''D_Moving'' pin drag the 'Direction' variable and make 'Select' block to easily choose the corresponding vector depending on the direction currently active in the detail. 'Left and 'Right' cases are split into components and fill the Y-component of the left-side case with the 'Speed' variable obtained from the 'Moveable' detail and multiplicated by the 'GlobalDelta' variable. For the right-side case use the same value just with an opposite sign. Below your 'AddActorLocalOffset' node place the deactivation of the 'TempMoving' detail be setting its state 'Enabled' to false. After all the above actions you should have something like that:{{ :en:toolworks:docs:apparatus-mechanism-moving-logic.png?nolink |}}What's actually going on here? As you may remember, we defined how we determine our keyboard input at some previous step (by adding a ''D_Moving'' details). Here we just move each actor with the pointed details (''D_Moving'' & ''D_Moveable'', only the pawn in the scene have this set) over their local Y-axis (for the camera view, it's actually moving to the left if Y-axis is > 0 and moving to the right otherwise). So, depending on the direction we obtained from the 'Moving' detail we move an actor across the scene. After doing so, we disable the ''D_Moving'' detail, so it won't be moving to the side anymore. Good. But what will happen when the player presses a <key>d</key> or a <key>a</key> key a second time? Do you remember the checkbox we pinned? The 'Reuse Disabled' in fact means that if the 'Subjective' has a disabled detail then the function will enable it and return as its output instead of creating a new one. So now you can run the game and check if it works. Use <key>a</key> & <key>d</key> keys to move the box around.
    - Also make a few additional changes and you'll also be able to jump. {{ :en:toolworks:docs:apparatus-jump.png?nolink |}} But the box isn't falling at all, because we haven't implemented the necessary logic in our Mechanism. So let's do that!    - Also make a few additional changes and you'll also be able to jump. {{ :en:toolworks:docs:apparatus-jump.png?nolink |}} But the box isn't falling at all, because we haven't implemented the necessary logic in our Mechanism. So let's do that!
    - Go back to 'BP_MainPawn' and a new 'BoxCollision' component to the 'DefaultSceneRoot'. Use the following transform:    - Go back to 'BP_MainPawn' and a new 'BoxCollision' component to the 'DefaultSceneRoot'. Use the following transform:
Line 56: Line 55:
  
 Anyways, that's it for this tutorial and the result should look similar to: {{youtube>oVE1FRIq8A8?medium}} Anyways, that's it for this tutorial and the result should look similar to: {{youtube>oVE1FRIq8A8?medium}}
 +[[https://github.com/toolworks/ApparatusBeginnerGuide|The project on github, take a look on the ApparatusLearn#1 branch]]
  
 ===== Conclusion ===== ===== Conclusion =====
  • en/toolworks/docs/apparatus/beginner.txt
  • Last modified: 2023/01/14 15:15
  • by vladius