acron.spring_arm

SpringArm3D – faithful reimplementation of Godot’s SpringArm3D.

Ported from godot/scene/3d/physics/spring_arm_3d.cpp::process_spring:

  • cast_direction = the arm’s own basis applied to its boom axis (world space);

  • motion = cast_direction * spring_length;

  • ray-cast from the arm’s world origin along motion; on a hit, subtract the margin and shorten the boom proportionally (motion_delta);

  • place the child (the camera) at origin + cast_direction * current_length, keeping the child’s own orientation.

Godot’s arm casts along local +Z because Godot cameras look down local -Z, so +Z points behind the camera. Acron cameras look down local +Y, so here the boom axis is local +Y: orient the SpringArm node so its +Y points behind the camera, and this class slides the camera in/out along it, pulling in on collisions.

collide_mask must be the SOLID-wall layers only. Casting against “player-only” barriers (railings, props the player collides with but bullets pass through) collapses the boom onto the player whenever such a barrier is behind the camera. A boom that ends up too short puts the camera inside the character (the player projects off-screen and the view reads as “a wall”). Smooth spring_length changes yourself if pops on wall transitions bother you.

SpringArm(parent, physics_world, collide_mask)

A collision-aware boom.