Skip to content

Search

Documentation

follow2d component

Pulls the node's body2d towards the pose of target every fixed step, with rapier's PD or PID controller. node.follow2d.reset_follow() forgets what a PID…

In questa pagina

2d · physics · 12 properties · 2D

Pulls the node's body2d towards the pose of target every fixed step, with rapier's PD or PID controller. node.follow2d.reset_follow() forgets what a PID summed.

In a scene, follow2d is the node key that applies it. A script reaches each property below as a field on node.follow2d: reading one asks the running component, and assigning one leaves the rest alone. The whole table is node.follow2d.get() and node.follow2d.set(table).

Properties

property type default description
follow_rotation bool true Whether the body is turned to the target's rotation too
integral_gain vec2 [1,1] How hard the gap in position summed over time pulls, per axis, with pid
kind enum pd Rapier's proportional-derivative controller, or the same with an integral that keeps pulling against a steady push One of pd, pid.
position_gain vec2 [60,60] How hard a gap in position pulls, per axis: about one over the fixed step closes it in one step
rotation_gain float 60 How hard a gap in rotation pulls
rotation_integral_gain float 1 How hard the gap in rotation summed over time pulls, with pid
spin_gain float 0.8 How much of a gap in spin a step corrects
target node — The node whose pose the body is pulled to; empty pulls nothing
target_angular_velocity float 0 The spin the body is pulled to match, radians a second in the file
target_linear_velocity vec2 [0,0] The velocity the body is pulled to match, in world units per second
translation_axes flags ["x","y"] The axes the body is pulled along One of x, y.
velocity_gain vec2 [0.8,0.8] How much of a gap in velocity a step corrects, per axis: 0 none, 1 all of it

Script functions

Methods of node.follow2d, the handle a node carrying this component exposes. Every handle also has get(), set(table), patch(table), has() and remove().

From physics2d:

method what it does
reset_follow() Forget what a pid follow summed, so it pulls from now as if it had just started.