Skip to content

PhysicsBody2D

Eduard Gushchin edited this page Jul 1, 2026 · 5 revisions

Home | API by Category | Complete API Index | API Compatibility

Field Value
Full name Electron2D.PhysicsBody2D
Namespace Electron2D
Kind class
Category Physics

Overview

Provides the base node for physical 2D bodies that participate in collision queries.

Syntax

public abstract class Electron2D.PhysicsBody2D : Electron2D.CollisionObject2D

Godot 4.7 C# profile compatibility

Profile: Electron2D 0.1.0 2D
Status: Partial / Not verified
Out of profile: yes
Godot reference: PhysicsBody2D

Base class for body nodes with shared PhysicsMaterialOverride and MoveAndCollide() kinematic movement helper.

Remarks

Electron2D.PhysicsBody2D is the shared base for Electron2D.StaticBody2D, Electron2D.RigidBody2D and Electron2D.CharacterBody2D. It exposes body-level movement helpers without exposing backend-specific handles.

Thread Safety

This type is not synchronized. Create and mutate nodes on the main scene thread.

Since

This type is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D
  • Electron2D.CollisionObject2D

Members

Member Kind Summary
PhysicsMaterialOverride Property Gets or sets the physics material overriding this body's default collision material.
Electron2D.PhysicsBody2D() Constructor Initializes a new instance of the PhysicsBody2D type.
MoveAndCollide(Electron2D.Vector2, System.Boolean, System.Single, System.Boolean) Method Moves this body along a motion vector and stops when it hits another body.

Member Details

PhysicsMaterialOverride

Kind: Property

public Electron2D.PhysicsMaterial PhysicsMaterialOverride { get; set; }

Summary

Gets or sets the physics material overriding this body's default collision material.

Remarks

The 0.1.0 Preview baseline stores this value in the internal body-state snapshot so future physics backends can combine material properties.

Value

The override material, or null to use the default body material.

Thread Safety

This property is not synchronized. Mutate it on the main scene thread.

Since

This property is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.PhysicsMaterial

Electron2D.PhysicsBody2D()

Kind: Constructor

public Electron2D.PhysicsBody2D()

Summary

Initializes a new instance of the PhysicsBody2D type.

Remarks

The new instance follows the lifetime and validation rules of its declaring type.

Thread Safety

This member is not synchronized. Call it from the thread that owns the related object unless the declaring type states otherwise.

Since

This API is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.PhysicsBody2D

MoveAndCollide(Electron2D.Vector2, System.Boolean, System.Single, System.Boolean)

Kind: Method

public Electron2D.KinematicCollision2D MoveAndCollide(Electron2D.Vector2, System.Boolean, System.Single, System.Boolean)(Electron2D.Vector2 motion, System.Boolean testOnly, System.Single safeMargin, System.Boolean recoveryAsCollision)

Summary

Moves this body along a motion vector and stops when it hits another body.

Remarks

The 0.1.0 Preview baseline performs a managed AABB sweep against Electron2D.StaticBody2D targets whose collision layers match this body's Electron2D.CollisionObject2D.CollisionMask.

When testOnly is false, the body position is advanced by either the full motion or the collision travel reported by Electron2D.KinematicCollision2D.GetTravel.

Parameters

  • motion: The relative motion to test and, unless testOnly is true, apply to this body.
  • testOnly: When true, the collision is reported without changing the body position.
  • safeMargin: Extra separation margin used by the managed AABB baseline when sweeping the body.
  • recoveryAsCollision: Whether recovery movement should be reported as a collision. The 0.1.0 Preview AABB baseline stores the value for API compatibility but does not run a separate recovery phase yet.

Returns

A Electron2D.KinematicCollision2D when the movement hit another body; otherwise, null.

Thread Safety

This method is not synchronized. Call it on the main scene thread.

Since

This method is available since Electron2D 0.1.0 Preview.

See Also

  • Electron2D.CharacterBody2D.MoveAndSlide
  • Electron2D.KinematicCollision2D

Clone this wiki locally