1. open bit.ly/2i46rdy in a browser to download “crash...

74
Download Starting Project 1. Open bit.ly/2I46RDy in a browser to download “crash-course-godot-3.zip” 2. Unzip the file. 3. In your file browser, open the folder within the zip, “crash-course-godot-3”.

Upload: others

Post on 02-Feb-2021

0 views

Category:

Documents


0 download

TRANSCRIPT

  • Download Starting Project1. Open bit.ly/2I46RDy in a browser to download

    “crash-course-godot-3.zip”2. Unzip the file.3. In your file browser, open the folder within the zip,

    “crash-course-godot-3”.

    https://bit.ly/2I46RDy

  • Crash Course Godot 3Making 3D games with open-source software

  • Goal● Get comfortable with Godot game editor● Create an interactive 3D environment● Learn lots of 3D development terms● A brief introduction in visual scripting

  • Supplementary materials● docs.godotengine.org/en/3.0/getting_started

    /step_by_stepa. Official site providing tutorials on how to

    use the game engine.b. Doubles as an in-depth manual!

    ● youtu.be/-D-IcbsdT04a. Recommended video tutorial

    http://docs.godotengine.org/en/3.0/getting_started/step_by_step/index.htmlhttp://docs.godotengine.org/en/3.0/getting_started/step_by_step/index.htmlhttps://youtu.be/-D-IcbsdT04

  • Importing Tutorial ProjectStep 1: Click “Import.”

  • Importing Tutorial ProjectStep 2: Click on “Browse.”

  • Importing Tutorial ProjectStep 3: Navigate to the “crash-course-godot-3,” and find the file, “project.godot”. Click “open.”

  • Importing Tutorial ProjectStep 4: Finally, click on “Import & Edit.”

  • Asset LicenseOriginal files obtained from:http://opengameart.org/content/machu-picchu● level.obj is a modified version of MPFull.blend from

    ctdabomb, released under CC-by-sa 3.0● grass.png is from samuncle, released under CC-by-sa

    3.0● rock.jpg is from Marianne Gagnon , release under

    CC-by-sa 3.0Link to CC-by-sa 3.0 license:https://creativecommons.org/licenses/by-sa/3.0/legalcode

    http://opengameart.org/content/machu-picchuhttps://creativecommons.org/licenses/by-sa/3.0/legalcode

  • About Godot 3

  • What is Godot 3?● A What-You-See-Is-What-You-Get (WYSIWYG) 3D & 2D

    Game Engine● Many built-in features

    ○ Physics, Sound, Scripting, Gamepad support, Plugins, and more!

    ● Builds to many platforms○ PC, Mac, Linux, HTML5 + WebGL, iOS (iPhone + iPad),

    Android, Windows 10

  • Licenses and Fees● Free forever!

    ○ Under the open-source MIT license■ You can change the engine code if you want to!

    ○ Build to Windows, Mac, Linux, HTML5 + WebGL, iOS, Android, and Windows 10

    ○ Has VR and AR support○ C#, Python-ish GDScript, and visual scripting support

    ■ Extensions available for actual Python, D, etc.○ Totally OK to sell your game! There’s no royalty fees.

  • Making a game

  • Setting Up the Project● Godot has a base assumption all scenes must meet.● Try selecting “Scene -> Save Scene”

  • Setting Up the Project● An error indicating that the scene must have exactly

    one tree root node.○ What does that mean?

    ● Close pop-up by clicking, “I see…”

  • Setting Up the Project● On the Scene Tree dock in the

    upper-right hand corner, click on the plus sign.

  • Setting Up the Project● Select “Spatial” on the pop-up dialog, and click,

    “Create.”○ This creates a new root node!○ Spatial is a node with…

    spatial information.

  • Scene Tree Dock● Displays the content of a scene in a tree

    hierarchy.● Every scene must have exactly one root

    node.● You can change the order of the objects

    by dragging them up and down.● Dragging objects into another turns that

    object into a child (I’ll go over this later).

  • As an Aside● Clicking the 3-dot button on the upper-right hand

    corner of every dock let’s one change it’s position.

  • Quick lexicon review● Node

    ○ Godot’s term for any individual object.○ Each node specializes in a certain functionality.○ Every entry in the Hierarchy pane is a node.

    ● Scene○ Godot’s term for files storing a collection of nodes.○ Store references to assets in the project.○ Has a *.tscn file extension.

    ● Assets○ Industry-wide term for any files used in the game.○ For Godot, that’s anything inside the project folder.

  • Setting Up the Project● Select “Scene -> Save Scene”● Enter a file name. This lesson uses “Main Level.tscn”

    ○ Name must end in .tscn● Click “Save.”

  • File System Dock● Displays the contents of the project.

    ○ Automatically syncs with the folder if there’s any changes

    ● Top-half displays the folders.○ “res://” is the project folder itself.

    ● Bottom-half displays the content of the selected folder.○ Has a search bar to make it easier to find assets

  • Add a Model to The Scene● Click on the folder, “assets” on

    the File System dock.● Drag-and-drop level.obj into

    the center of the screen.

  • Add a Light to The Scene● On Scene Tree dock, click the

    plus button.● Search for “light” and select

    “DirectionalLight.”● Click “Create.”

  • Add a Light to The Scene● Rotate the directional light in

    the Scene pane by clicking-and-dragging the transparent rings.

    ● Press Ctrl+S/Cmd+S to save the scene

  • Quick lexicon review● Models

    ○ Industry-wide term for 3D sculpture files.○ Can contain animations.○ Usually made in a specialized program, e.g. Maya, Blender, etc.

  • Importing 3D modelsGodot can natively import:● COLLADA (*.dae)

    ○ Supports UV-mapping, animations.● Wavefront (*.obj)

    ○ Supports UV-mapping.● glTF 2.0 (*.gltf)

    ○ Supports UV-mapping, animations, and materials.

  • About Lighting● Directional Light

    ○ A sunlight emitted in one direction● Omni Light

    ○ A glow emitting from a single point● Spotlight

    ○ A cone-shaped light used to simulate flashlights and spotlights

  • Scene Pane● A 3D, tabbed view of a scene

    where objects can be positioned, rotated, and scaled.

    ● Nodes selected in the Hierarchy-pane are also selected in the Scene-pane, and vice versa.

  • Navigating the scene pane● 3-button mouse:

    ○ Left-click to select objects.○ Hold right mouse button to rotate camera around camera position.○ Scroll wheel to zoom in and out.○ Click and hold on the scroll wheel to rotate camera around the point

    the camera is focusing on.○ Hold shift, then click and hold on the scroll wheel to pan.

  • Manipulating game objects● Object controls, from left to right:

    ○ All (Q)○ Translate (W)○ Rotate (E)○ Scale (R)

    ● Controls to toggle object’s reference point:● Play Game controls, from left to right:

    ○ Play game from starting scene (more on that later)○ Pause game○ Stop game○ Play current scene○ Play a selected scene (opens a pop-up)

  • Creating Materials● Select “MeshInstance” in the Scene

    Tree dock.● In the Inspector dock, at the lower

    right-hand corner, expand “Material.”

    ● Under material “0,” click the “v” button and select “New SpatialMaterial.”

    ● Click on the new material.

  • Adding Texture to Model● Expand the “Albedo” group.● From the File System dock, under the “assets” folder,

    drag-and-drop the “grass.png” to the “Texture” field.● Click the back button.

    ○ On upper right-hand cornerof the dock.

  • Adding Texture to Model● Repeat the steps for

    Material “1,” using file “rock.jpg”.

  • Inspector Dock● Displays the properties and

    details on a selected node in the Scene Tree dock.

    ● One can edit the properties of an object here.

    ● Some properties has yet another inspector; use the 2 arrows on the upper right-hand corner to move forward or back inspectors.

  • Quick lexicon review● Material

    ○ Industry-wide term for what the quality surface of a model is supposed to look like (e.g. metal, plastic, non-shiny stuff)

    ○ In Godot, materials can be either embedded property or files (*.tres).■ Changing a material file’s properties will update all game objects

    with the same material○ Models retain information on how materials are mapped to its surface

    ● Textures○ Industry-wide term for images that represents how a model is

    supposed to be painted○ Models usually contains coordinates (called UV) that indicate how a

    texture is supposed to be mapped on the model

  • Supported ImagesIn Godot, ● PNGs (*.png)● JPEGs (*.jpg, *.jpeg)● and more!

  • Adding CameraGodot can embed existing scenes into another scene.● From the File System

    dock, under the “assets” folder, drag “FPS Controller.tscn” into the Scene editor.

  • Playing the Game● Press the play button.● Observe that we get another pop-up.● What does it mean?

  • Playing the GameGodot requires that the project settings defines which scene to start the game on. Fortunately, there’s a convenient shortcut to set this setting.● Click on “Select.”● On the file browser,

    the current sceneshould be selected.Just click, “Open.”

    ● This sets the setting!

  • Playing the GameThe game should now play!● ...except the player is falling through the floor…● What’s missing?

  • Adding a ColliderThe ground needs a collider with the same shape as the model. Fortunately, Godot has a shortcut.● Select “MeshInstance” in the Scene Tree dock.● In the Scene editor, click the “Mesh” button.● Select “Create

    Trimesh StaticBody.”

  • Playing the Game● Press the play button.● Use the mouse to look around, arrow keys (or WASD)

    to move, and space to jump.● Left-click to shoot.

  • Quick lexicon review● Colliders

    ○ Industry-wide term for shapes representing the boundaries of an object

    ○ Used by the physics engine to determine where objects collide

  • Types of Collider Nodes● Static Body

    ○ A node for handling non-interactive objects.○ No physics, e.g. gravity, is applied to this node.○ Can be animated.○ Needs at least one collider node as children for it to do anything.

    ● Collision Shapes○ A collider node for a predefined shapes.○ Can be generated from model’s data.○ Requires a parent Body node (like Static Body).

    ● Collision Polygon○ A collider node where the polygon can be defined by the user.○ Requires a parent Body node (like Static Body).

  • Adding Premade Graphics● Under the Scene Tree dock,

    right-click the root node, “Spatial.”

    ● In the pop-up, select MeshInstance, and click, “create.”

    ● Observe that a new node, MeshInstance2 was created, but nothing appears in Scene Editor.○ Note: for brevity, these node creation

    steps will be shortened to, “create X”

  • Adding Premade Graphics● In the Scene Tree dock, left-click MeshInstance2.● In the Properties dock, change the mesh to “New

    CubeMesh.”● A floating cube will appear in the Scene editor, but we

    know from previous example this cube has no colliders.

  • ● Right-click “MeshInstance2,” and create a StaticBody node.

    ● Clicking on the warning symbol brings up a pop-up explaining the StaticBody expectschildren.

    ● Click “OK” to close the dialog.● Right-click StaticBody

    and create aCollisionShape.

    Adding Premade Collider

  • Adding Premade Collider● CollisionShape node will have a warning indicating no

    shape is defined.● Select the CollisionShape to update

    the inspector.● In the Inspector dock, click on the

    arrow next to the Shape field.● Select “New BoxShape.”● Play the game, and shoot the cube!

  • Adding Premade Collider● Why go through such a lengthy method to put together

    a collider?○ A shorter method to create tri-mesh collider exists, after all.

    ● Tri-mesh collider works well for complex shape that rarely moves, but it’s bad for performance.

    ● Premade collision shapes, like cubes and spheres are much faster!

    ● Let’s make the cube react to the bullets (and gravity)!

  • Adding Interactive Stuff● Right-click on StaticBody, and click, “Change Type.”● Change the type to Rigidbody.

    ○ Notice the icon changes, but name doesn’t.○ Icon represents type.○ Name is customizable.

    ● Play the game, and shootthe cube.

    ● Try shooting at the groundbelow the cube.

  • Adding Interactive Stuff● Drag-and-drop the StaticBody above the MeshInstance2.

    ● Next, drag MeshInstance2 under StaticBody. Play the game!

  • Quick lexicon review● Rigid Body

    ○ Industry-wide term for a moving and/or interactive physics objects○ Contains information such as mass, drag, and center-of-gravity○ Turns a group of colliders (including those in the children) into a

    single, interactable shape● Child

    ○ Industry-wide term for an object whose position, scale, and rotation follows that of another object: the parent

    ○ In Godot, they appear as nested entries in the Hierarchy tree view○ Trivia: this “following parent” calculation process is known as forward

    kinematics, a term in 3D animations

  • Adding a Sound● In the Scene Tree dock, right-click

    StaticBody, and create AudioStreamPlayer3D node.

    ● Drag file “hit.wav” to thethe property, “Stream.”

    ● Now we need the sound toplay each time the cube hitsSomething. How?

  • Adding a Script● Select StaticBody, then click the

    scroll with the plus sign on the upper right-hand corner of the dock.

    ● In the pop-up, select the Language, “VisualScript,” and change the path to “res:///PlaySound.vs”

    ● Click, Create.

  • Code the Script● While StaticBody is still selected,

    click on the “Node” tab next to the Inspector.

    ● Double-click on “body_entered( Object body )”

    ● In the pop-up, select “StaticBody,” and click, “Connect.”

  • Code the Script● Drag-and-drop the

    AudioStreamPlayer3D from the SceneTree node to the Script Editor.

    ● In the pop-up, select “play( float from_position )”, then click “Open.”

    ● Then connect the two nodes’ white arrows:

  • Finishing the Sound Effect● Play the game.

    ○ Notice there’s no sound effect. Something is missing!

    ● In the Scene dock, select StaticBody.

    ● Click the Inspector tab.● Check the “Contact Monitor”

    property.● Change “Contacts Reported”

    to 1. Play the game.

  • Script Summary● Visual Scripting takes a graph-based approach.● First, a function based on an event or signal triggers.● Then the functions follows the white line to the next

    node.● This node process the command; it then decides which

    white triangle to follow through next (if any).● If there is a white line from that triangle, it follows that

    to the next node.● Repeat until it reaches an end.

  • Importing SoundGodot can natively import:● WAV (*.wav)

    ○ Best for short sound effects● OGG (*.ogg)

    ○ Best for music, especially PC and consoles

  • Duplicating the Cube● Right-click on StaticBody, and select

    “Save Branch as Scene.”● Save the scene as “Cube.tscn”● Select Spatial (the root node) in Scene

    Tree dock.● Drag-and-drop Cube.tscn in the Scene

    editor everywhere!a. Remember, scenes can be added to another like

    a normal node!

  • Building an Executable● Save the scene with

    Ctrl+S/Cmd+S.● In the file menu, select

    "Project -> Export"● In the pop-up dialog, click

    “Add…” and select your platform.

  • Building an Executable● Click “Export Project.”● Select a folder that isn’t in your project.● Open the folder, and play

    the build!

  • Congratulations!Any questions?

  • Polishing Lighting● Select “DirectionalLight,” and take a look

    at the properties.● Try changing any of the properties

    highlighted on the right.○ Highly recommend checking the “Shadow ->

    Enabled” checkbox!

  • Polishing Post-Processing● Double-click the file, “default_env.tres,”

    then check the Inspector.● See what happens if you change any of

    the “Background” properties.● See what happens if you change any of

    the “Ambient Light” properties.

  • Polishing Post-Processing● See what happens if you change any of

    the “Dof Far Blur” properties.○ Note: DOF = Depth-of-Field.

    ● See what happens if you change any of the “Glow” properties.

  • Polishing Post-Processing● Did anything change?

  • Polishing Physics● Select “StaticBody,” and take a look at

    the properties.● Try changing any of the properties

    highlighted on the right.○ Remember to play the game on each change,

    then shoot the cube to see what happens!

  • Polishing Materials● Select “MeshInstance,” then click on one

    of the materials under the Properties dock.● Try changing any of the properties

    highlighted on the right.○ Highly recommend adjusting the “Metallic” and

    “Roughness” properties.

  • Polishing Materials● Did anything change?

  • Reading Scripts● Click on the scroll

    icon next to “FPS Controller” in Scene Tree dock.

    ● In the script editor, click “FPS Controller.vs”

    ● Finally, click the “_process” function.

  • Reading Scripts● The function “_process( float delta )” runs every frame

    (i.e. all the time).● Can you decipher what’s going on with the script?

  • Polishing Wrap-Up!● What kind of polish did you make?