38 lines
1.5 KiB
Org Mode
Executable file
38 lines
1.5 KiB
Org Mode
Executable file
#+title: Section 04 - Lesson 05, 06 | collision shapes and resources, falling]
|
|
#+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/45069805#overview][S04:L50.05 - video]]
|
|
- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45069813#overview][S04:L51.06 - video]]
|
|
|
|
* Notes
|
|
- we need a collisionshape to tell the physics engine the boundaries of this plane
|
|
- add a child node CollisionShape2D to the CharacterBody2D root node of this scene
|
|
- in the Inspector, click on Shape to determine what type of shape we are using
|
|
|
|
** create script for falling
|
|
- hit the 'attach new or existing script' button on the upper right corner of the scene dialog
|
|
- make sure that the script:
|
|
- inherits from CharacterBody2D
|
|
- the Template is 'Node Default'
|
|
- Built in Script is OFF
|
|
|
|
*** script functions
|
|
- ready() starts when node is set
|
|
- process() is called every time a frame is called
|
|
- NOTE: better to use physics_process because that's what the engine is going to use
|
|
- so change process to physics process
|
|
#+BEGIN_SRC gdscript
|
|
_physics_process(delta: float) ->void:
|
|
#+END_SRC
|
|
|
|
** CharacterBody2D
|
|
*** properties
|
|
**** velocity
|
|
- has an 'x' and a 'y'
|
|
|
|
**** up_direction
|
|
- tells physics engine how to know if we are on a floor or not
|
|
- can tell us if we are on a ceiling or a wall
|