PhysicsTestMotionParameters2D
Inherits: RefCounted < Object
Description
Section titled “Description”Provides parameters for PhysicsSystem2D.body_test_motion().
By changing various properties of this object, such as the motion, you can configure the parameters for PhysicsSystem2D.body_test_motion().
Note: For optimal performance results, it is recommended to create this object in advance, store it, and reuse it for every subsequent query.
Properties
Section titled “Properties”| Type | Name | Default |
|---|---|---|
| bool | collide_separation_ray |
false |
| Array[RID] | exclude_bodies |
[] |
| Array[int] | exclude_objects |
[] |
| Transform2D | from |
Transform2D(1, 0, 0, 1, 0, 0) |
| float | margin |
0.08 |
| Vector2 | motion |
Vector2(0, 0) |
| bool | recovery_as_collision |
false |
Property descriptions
Section titled “Property descriptions”collide_separation_ray
bool collide_separation_ray = false
If set to true, shapes of type PhysicsSystem2D.SHAPE_SEPARATION_RAY are used to detect collisions and can stop the motion. Can be useful when snapping to the ground.
If set to false, shapes of type PhysicsSystem2D.SHAPE_SEPARATION_RAY are only used for separation when overlapping with other bodies. That’s the main use for separation ray shapes.
exclude_bodies
Array[RID] exclude_bodies = []
Optional array of body RID to exclude from collision. Use CollisionObject2D.get_rid() to get the RID associated with a CollisionObject2D-derived node.
exclude_objects
Array[int] exclude_objects = []
Optional array of object unique instance ID to exclude from collision. See Object.get_instance_id().
from
Transform2D from = Transform2D(1, 0, 0, 1, 0, 0)
Transform in global space where the motion should start. Usually set to Entity2D.global_transform for the current body’s transform.
margin
float margin = 0.08
Increases the size of the shapes involved in the collision detection.
motion
Vector2 motion = Vector2(0, 0)
Motion vector to define the length and direction of the motion to test.
recovery_as_collision
bool recovery_as_collision = false
If set to true, any depenetration from the recovery phase is reported as a collision; this is used e.g. by CharacterBody2D for improving floor detection during floor snapping.
If set to false, only collisions resulting from the motion are reported, which is generally the desired behavior.
