Intersection
- Want to know when objects come into contact → Collision Detection
- Want to know what to do when this happens → Collision Response
Collision Objects
extend CollisionObject2D
Area2D
defines a regions of 2D space and provides detection and influence
- emit signals when bodies enter or exit
- can override physics parameters in an area (gravity, damping)
StaticBody2D
not moved by the physics engine
- used for environment objects (with no dynamic behavior)
- can impart motion or rotation to a colliding body
RigidBody2D
implements simulated 2D physics
- apply forces (gravity, impulses,...) to it and physics engine calculates
- Modes
- Rigid: default
- Static: behaves like StaticBody2D
- Character: ~Rigid, no rotation
- Kinematic: ~KinematicBody2D
KinematicBody2D
provides collision detection, but no physics
- movement + collision response implemented in code
- position set directly
- move_and_collide(), move_and_slide()
- moves body along a given vector, will stop if collision detected
- returns a collision object (KinematicCollision2D)
- only do body movement in _physics_process()