Godot
Physical Objects

A rigidbody is a physical object that falls, bounces etc.

A staticbody is a physical object that does not move.

Both of the above need to have the following child nodes:

  • Sprite or AnimatedSprite (so you can see the object)
  • Collision (to define the physical shape)
Create a physical object
Use a button to apply an impulse
Add and play animations (or more detailed explanation, including sprite sheets)
Make a player that can jump

First you will need something for the player to stand on.

  1. Create a StaticBody2D node
  2. Add a Sprite2D node as a child to the StaticBody2D and set its texture in the Inspector
  3. Add a CollisionShape2D node as a child to the StaticBody2D and set its shape in the inspector
  4. Select the StaticBody2D and use the Move tool to move it to a good place in the scene

Now you can create your player:

  1. Create a RigidBody2D node
  2. Add a Sprite2D node as a child to the RigidBody2D and set its texture in the Inspector
  3. Add a CollisionShape2D node as a child to the RigidBody2D and set its shape in the Inspector
  4. Select the RigidBody2D and use the Move tool to move it to a good place in the scene
  5. Attach a script to the Rigidbody2D and save it
  6. Put this code in the script:


Make a top-down drivable car
Destroy object on collision
  1. Add the breakable object to the "breakable" group (from the Node tab next to Inspector)
  2. Add a script to the breaker object
  3. Connect the body_entered signal on the breaker object to its script
  4. Use this code instead of pass:    

    if body.is_in_group("breakable"):
            body.queue_free()

  5. In the Inspector for the breaker object, set Contacts Reported to 2 and Contact Monitor to On.
Make an object that can be dragged
  1. Create an Area2D node
  2. Add a Sprite2D node as a child of the Area2D and set its texture in the inspector
  3. Add a CollisionShape2D node as a child of the Area2D, set its shape in the Inspector, then adjust it to match the Sprite
  4. Attach a script to the Area2D node and save it
  5. In the Node tab (near the Inspector) find the input_event signal, and double click it, then choose the Area2D and click Connect
  6. In the script, add this code:


Play a sound
  1. Export the sound as .ogg file and put it in your Godot project folder
  2. Select the .ogg file in the FileSystem tab in Godot, and switch from Scene tab to Import tab
  3. Untick Loop, and click ReImport
  4. Switch back to Scene tab and add an AudioStreamPlayer2D node as a child of the node your script is on
  5. Drag the .ogg file as the Stream in the Inspector
  6. In your script, use this code to play the sound:

    $AudioStreamPlayer2D.play()