- I wondered why the Player node was an Area2D and yet the Enemy nodes were RigidBody2D. Looked at the documentation and found this: RigidBody2D implements full 2D physics. It cannot be controlled directly, instead, you must apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, rotation, react to collisions, and affect other physics bodies in its path.
- That makes me think that since the Area2D was to be player controlled via inputs, the enemies would use RigidBody2D and be controlled by physics (science!)
- The Group Selected Nodes should be clicked whenever you create a 2D node. Make that a habit. I was doing that wrong.
- The canvas size is the purple line
- In scripts, position is an existing local variable for Node2D. It’s also in the Inspector under Transform.
- You can mouse-over a node and a popup will reveal it’s type.
- clamp will prevent Player from going offscreen, I could have used this for my TileMapLayers tutorials…
- TODO: Study up on Vector Math.
- Player will use the _on_body_entered listener and emit a custom hit signal.
- Mobs are instances, and when they leave the screen, their VisibleOnScreenNotifier2D child will notify the parent with _on_visible_on_screen_notifier_2d_screen_exited(), which will then have the Mob’s Node.queue_free(). This removes the instance from memory.
A script’s functions can be found here:
Interesting things in the Reference section of the documentation:
- The Main scene is just a Node, not a Node2D. This is because it will be a container for handling game logic and does not require 2D functionality. It will create Instances of other things, such as Player.
- Player emits the hit signal, connected to a new function “game_over” in the Main scene.
The scene that runs when you press Play is called the “Main Scene”. It is colored blue here:
You can change this by right-clicking -> Set as Main Scene
Leave a Reply