mirror of
https://github.com/godotengine/godot.git
synced 2024-11-21 19:42:43 +00:00
Updated tutorial_physics_2d (markdown)
parent
8e41868672
commit
2bcee8a03d
@ -131,13 +131,30 @@ In fact, what CollisionPolygon does is to decompose the polygon in convex shapes
|
||||
|
||||
### RigidBody2D
|
||||
|
||||
This type of body simulates newtonian physics. It has mass, friction, and the 0,0 coordinates simulates the center of mass. When real physics are needed, [RigidBody2D](class_rigidbody2d) is the node to use. The motion of this body is affected by gravity and/or other bodies.
|
||||
This type of body simulates newtonian physics. It has mass, friction, bounce, and the 0,0 coordinates simulates the center of mass. When real physics are needed, [RigidBody2D](class_rigidbody2d) is the node to use. The motion of this body is affected by gravity and/or other bodies.
|
||||
|
||||
Rigid bodies are usually active all the time, but when they end up in resting position and don't move for a while, they are put to sleep until something else wakes them up. This saves an enormous amount of CPU.
|
||||
|
||||
RigidBody2D nodes update their transform constantly, as it is generated by the simulation from a position, linear velocity and angular velocity. As a result, **this node can't be scaled**. Scaling the children nodes should work fine though.
|
||||
|
||||
As a plus, as this is very common in games, it is possible to change a RigidBody2D node to behave like a Character (no rotation), StaticBody or KinematicBody according to different situations (example, an enemy frozen by an ice beam becomes a StaticBody)
|
||||
|
||||
The best way to interact with a RigidBody2D is during the force integration callback. In this very moment, the physics engine synchronizes state with the scene and allows full modification of the internal parameters (otherwise, as it may be running in a thread, changes will not take place until next frame). To do this, the following function must be overridden:
|
||||
|
||||
```python
|
||||
func _integrate_forcres(state):
|
||||
[use state to change the object]
|
||||
```
|
||||
|
||||
The `state` parameter is of type [Physics2DDirectBodyState](class_physics2ddirectbodystate). Please do not use this object (state) outside the callback as it will result in an error.
|
||||
|
||||
### Area2D
|
||||
|
||||
Areas in Godot physics have two main roles:
|
||||
|
||||
1. Override the space parameters for objects entering them (ie. gravity, gravity direction, gravity type, density, etc).
|
||||
2. Monitor when rigid or kinematic bodies enter or exit the area.
|
||||
|
||||
### Physics Global Variables
|
||||
|
||||
### FPS & Fixed Process Callback
|
||||
### FPS & Fixed Process Callback
|
Loading…
Reference in New Issue
Block a user