Compare commits
2 commits
51f58bb19f
...
c59e28d3a8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c59e28d3a8 | ||
|
|
20a5bea72f |
4 changed files with 113 additions and 2 deletions
BIN
_share/media/img/albert/section-05/lesson-06/ex_01a.png
Normal file
BIN
_share/media/img/albert/section-05/lesson-06/ex_01a.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 135 KiB |
|
|
@ -1,5 +1,5 @@
|
|||
#+title:Flyin#+title: Section 05 - Lesson 06 | Plane Movement
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" hare/media/css/godot.css" />
|
||||
#+title: Section 05 - Lesson 06 | Plane Movement
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../../_share/media/css/godot.css" />
|
||||
#+OPTIONS: H:6
|
||||
|
||||
* Links
|
||||
|
|
@ -9,3 +9,104 @@
|
|||
* Notes
|
||||
- the more complex the collision shape the more computations
|
||||
- if you concentrate on good games, you'll notice the collisions are actually straightforward
|
||||
|
||||
** collision shape
|
||||
*** adding a collision shape
|
||||
- click on root node
|
||||
- add child CollisionShape2D
|
||||
- pane scene->collision_shape_2D
|
||||
- pane inspector->CollisionShape2D->Shape
|
||||
- select new CircleShape2D
|
||||
- use shape handles to adjust
|
||||
|
||||
*** issues with collisions
|
||||
- we want the collision shape to be good
|
||||
- but the more complex the collision the more computations
|
||||
- focus on the game flow, not perfecting the modeling
|
||||
|
||||
|
||||
*** circle shape resource
|
||||
- click inside the Shape dropdown on the CircleShape2D item
|
||||
- it will open up and show you details about CircleShape2D
|
||||
- radius
|
||||
- resource
|
||||
- local to scene
|
||||
- path
|
||||
- name
|
||||
|
||||
- currently the resource is embedded in the scene
|
||||
|
||||
**** if you want to save the resource for reuse
|
||||
- click on the arrow next to the Shape dropdown
|
||||
- click save or save as
|
||||
|
||||
** add a script
|
||||
- SELECT THE ROOT NODE "plane"
|
||||
- click on the Scene green plus to add a script
|
||||
#+attr_html: :width 600
|
||||
file:../../_share/media/img/albert/section-05/lesson-06/ex_01a.png
|
||||
|
||||
*** in dialog
|
||||
- template: select Node default
|
||||
- built in script: off
|
||||
|
||||
*** coding
|
||||
- in a phsycis body we just give vectors
|
||||
- let the physics engine deal with positioning
|
||||
|
||||
- CharacterBody2D has a velocity variable which you can set
|
||||
- Vector2D velocity
|
||||
- x, y
|
||||
- how much we want to move in x and y
|
||||
|
||||
- function bool move_and_slide()
|
||||
- updates our position
|
||||
- updates the velocity if we collide with something
|
||||
|
||||
- after move_and_slide has been invoked we call other funcitons
|
||||
- is_on_ceiling
|
||||
- is_on_floor
|
||||
- etc
|
||||
|
||||
- upDirection method sets what is "up"
|
||||
- default x: 0, y: -1
|
||||
- (0, 1) ceiling is now floor
|
||||
- (1, 0) the left side is the ceiling
|
||||
|
||||
*** default gravity
|
||||
- you can access gravity from Project Settings
|
||||
|
||||
#+begin_src gdscript
|
||||
var _gravity: float = ProjectSettings.get("physics/2d/default_gravity")
|
||||
#+end_src
|
||||
|
||||
*** manipulating physics nodes
|
||||
- use _physics_process instead of _process
|
||||
|
||||
- process is invoked every frame
|
||||
- physics process is invoked at about half that rate
|
||||
|
||||
** creating boundaries
|
||||
*** create barrier scene
|
||||
**** initialize the scene
|
||||
- create a new scene
|
||||
- don't select one of the default nodes as the root
|
||||
- use the + symbol in Scene to select a StaticBody2D as the root node
|
||||
|
||||
**** add boundaries
|
||||
- create 2 CollisionShape2D nodes
|
||||
- on each set shape to WorldBoundaryShape2D
|
||||
|
||||
- lower node
|
||||
- move the boundary to the bottom of the viewing area
|
||||
|
||||
- top node
|
||||
- move the boundary a little bit above so as to give the plane some room to bounce through the ceiling
|
||||
- click on the Shape dropdown of WorldShape2D to open additional values
|
||||
- set the direction to down
|
||||
- in Normal, change y from -1 to 1, so it points down instead of up
|
||||
|
||||
- save scene
|
||||
|
||||
*** add barrier to game scene
|
||||
- instantiate as a child node in the game scene
|
||||
|
|
|
|||
9
_subsections/sec05/lesson-07.org
Normal file
9
_subsections/sec05/lesson-07.org
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#+title: Section 05 - Lesson 07 | Plane Jump Movement
|
||||
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../../_share/media/css/godot.css" />
|
||||
#+OPTIONS: H:6
|
||||
|
||||
* Links
|
||||
- [[../../toc.org][TOC - Godot Notes]]
|
||||
- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/49010965#overview][S05:L07 - video]]
|
||||
|
||||
* Notes
|
||||
1
toc.org
1
toc.org
|
|
@ -41,3 +41,4 @@
|
|||
- [[./_subsections/sec05/lesson-04.org][Lesson 04 | Physics Nodes Review]]
|
||||
- [[./_subsections/sec05/lesson-05.org][Lesson 05 | Resources and the Plane]]
|
||||
- [[./_subsections/sec05/lesson-06.org][Lesson 06 | Plane Movement]]
|
||||
- [[./_subsections/sec05/lesson-07.org][Lesson 07 | Plane Jump Solution]]
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue