411 REFERENCE · Wikibooks
Guide to the Godot game engine/Physics
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Input Saving and loading
Physics is used in many games, for many different things, such as falling, colliding into a wall, jumping, and so forth.
staticbody2d StaticBody2D and staticbody StaticBody3D
A StaticBody is a collision body that is not meant to move. While it can move, it should not be used for characters.
A static body may be scaled with no problems.
It is the fastest collision body type. It should be used for the environment and other non-movable things.
rigidbody2d RigidBody2D and rigidbody RigidBody3D
A RigidBody is an object that is affected by gravity. It usually is not used for characters as it is hard to control, but can be used in physics simulation games as it is quite accurate.
It cannot be scaled in any way!
kinematicbody2d KinematicBody2D and kinematicbody KinematicBody3D
A KinematicBody is a body that is intended to be given a script to move. It can also be used as a way to detect for hitting an object or surface.
Kinematic bodies work well for characters, but should not be used to simulate advanced physics.
area2d Area2D and area Area3D
An Area can be used to detect for other Areas, RigidBodies, or KinematicBodies. Upon overlap, a signal is emitted, and another is emitted when the object leaves.
If the camera/audio listener is inside the Area, it is possible to change the effects of sounds. E.g: to muffle car noises when jumping into water. You can do this by changing the "AudioBus" properties, and selecting a bus. You should make a "muffled" bus for this to work, and audio_bus_override must be set to true. (This is the overrided default audio bus, meaning the car noises must not use an audio bus. It will not layer the bus on top of others.).
collisionshape2d CollisionShape2D and collisionshape CollisionShape3D
In order for a collision object to collide with another, it needs one or more CollisionShape or ColisionPolygon children. CollisionShapes need an object defined to set their shape and size, and CollisionPolygons need multiple edges (at least 3) defined.
Collision mask and layers
Each object can have masks and layers. If at least one mask is equal to the overlapping object's layer, the two objects will be considered to have collided. This can be used to make the player collide with the floor, walls and enemies, but not other players, or only the floor and walls.
Each layer can be given a name in Project Settings -> Layer Names -> 2d Physics and Project Settings -> Layer Names -> 3d Physics. This improves readability, and decreases the chance of bugs. Here's an example:
Layer 1: World (walls, floors, bridges, ect)
Layer 2: Player
Layer 3: Enemies
Layer 4: Projectiles
Etc.
Soft world
If your 3D game uses softbody SoftBody, you can simulate objects that deform when another object collides with it. Useful for capes and curtains. If not used, it is best to turn off Project Settings -> Physics -> 3d -> Active Soft World to increase performance.
Physics engines
3D
GodotPhysics: Simple and functional. Incompatible with some collision shapes.
Bullet: The deafult. Constantly checks for collision, missing fewer collisions, but having more performance cost. Use if your game has fast moving objects, like racecars or bullets.
2D
GodotPhysics: The default. Simple and functional.
<noinclude>
Input Saving and loading
50%