2D

RigidBody2D

Dynamic 2D physics body.

Body with velocity, gravity, damping, sleep, and rotation lock fields.

Base node: Node2D

Source: perro_source/core/perro_nodes/src/nodes/physics_2d.rs

Fields

enabledlinear_velocityangular_velocitygravity_scalelinear_dampingangular_dampinglock_rotation
pub struct RigidBody2D {    pub base: Node2D,    pub enabled: bool,    pub linear_velocity: Vector2,    pub angular_velocity: f32,    pub gravity_scale: f32,}

Scene template

[node_instance]tags = ["runtime", "demo"]parent = @rootscript = "res://script.rs"script_vars = { speed = 4.0, health = 100 }   [RigidBody2D]    enabled = true    linear_velocity = (120, 48)    angular_velocity = (120, 48)    gravity_scale = (1, 1)    linear_damping = 1.0  [/RigidBody2D][/node_instance]

Script API

Create

let node_id = create_node!(ctx, RigidBody2D, "Spawned Node", ["enemy", "runtime"], parent_id);

Access / mutate

let value = with_node!(ctx, RigidBody2D, node_id, |node| {    node.enabled}); let pair = with_node!(ctx, RigidBody2D, node_id, |node| {    (node.enabled, node.linear_velocity)}); with_node_mut!(ctx, RigidBody2D, node_id, |node| {    node.enabled = true;});