Skip to content

LookAtModifier3D

Inherits: SkeletonModifier3D < Entity3D < Entity < Object

The LookAtModifier3D rotates a bone to look at a target.

This SkeletonModifier3D rotates a bone to look at a target. This is helpful for moving a character’s head to look at the player, rotating a turret to look at a target, or any other case where you want to make a bone rotate towards something quickly and easily.

When applying multiple LookAtModifier3Ds, the LookAtModifier3D assigned to the parent bone must be put above the LookAtModifier3D assigned to the child bone in the list in order for the child bone results to be correct.

Type Name Default
int bone -1
String bone_name ""
float duration 0.0
Tween.EaseType ease_type 0
SkeletonModifier3D.BoneAxis forward_axis 4
int origin_bone
String origin_bone_name
EntityPath origin_external_node
OriginFrom origin_from 0
Vector3 origin_offset Vector3(0, 0, 0)
float origin_safe_margin 0.1
float primary_damp_threshold
float primary_limit_angle
float primary_negative_damp_threshold
float primary_negative_limit_angle
float primary_positive_damp_threshold
float primary_positive_limit_angle
Vector3.Axis primary_rotation_axis 1
bool relative false
float secondary_damp_threshold
float secondary_limit_angle
float secondary_negative_damp_threshold
float secondary_negative_limit_angle
float secondary_positive_damp_threshold
float secondary_positive_limit_angle
bool symmetry_limitation
EntityPath target_node EntityPath("")
Tween.TransitionType transition_type 0
bool use_angle_limitation false
bool use_rest_for_limitation
bool use_secondary_rotation true
Returns Method
float get_interpolation_remaining() const
bool is_interpolating() const
bool is_target_within_limitation() const

OriginFrom

enum OriginFrom

ORIGIN_FROM_SELF = 0

The bone rest position of the bone specified in bone is used as origin.

ORIGIN_FROM_SPECIFIC_BONE = 1

The bone global pose position of the bone specified in origin_bone is used as origin.

Note: It is recommended that you select only the parent bone unless you are familiar with the bone processing process. The specified bone pose at the time the LookAtModifier3D is processed is used as a reference. In other words, if you specify a child bone and the LookAtModifier3D causes the child bone to move, the rendered result and direction will not match.

ORIGIN_FROM_EXTERNAL_NODE = 2

The global position of the Entity3D specified in origin_external_node is used as origin.

Note: Same as ORIGIN_FROM_SPECIFIC_BONE, when specifying a BoneAttachment3D with a child bone assigned, the rendered result and direction will not match.

bone

int bone = -1

Index of the bone_name in the parent Skeleton3D.

bone_name

String bone_name = ""

The bone name of the Skeleton3D that the modification will operate on.

duration

float duration = 0.0

The duration of the time-based interpolation. Interpolation is triggered at the following cases:

  • When the target node is changed

  • When an axis is flipped due to angle limitation

Note: The flipping occurs when the target is outside the angle limitation and the internally computed secondary rotation axis of the forward vector is flipped. Visually, it occurs when the target is outside the angle limitation and crosses the plane of the forward_axis and primary_rotation_axis.

ease_type

Tween.EaseType ease_type = 0

The ease type of the time-based interpolation. See also Tween.EaseType.

forward_axis

SkeletonModifier3D.BoneAxis forward_axis = 4

The forward axis of the bone. This SkeletonModifier3D modifies the bone so that this axis points toward the target_node.

origin_bone

int origin_bone

Index of the origin_bone_name in the parent Skeleton3D.

origin_bone_name

String origin_bone_name

If origin_from is ORIGIN_FROM_SPECIFIC_BONE, the bone global pose position specified for this is used as origin.

origin_external_node

EntityPath origin_external_node

If origin_from is ORIGIN_FROM_EXTERNAL_NODE, the global position of the Entity3D specified for this is used as origin.

origin_from

OriginFrom origin_from = 0

This value determines from what origin is retrieved for use in the calculation of the forward vector.

origin_offset

Vector3 origin_offset = Vector3(0, 0, 0)

The offset of the bone pose origin. Matching the origins by offset is useful for cases where multiple bones must always face the same direction, such as the eyes.

Note: This value indicates the local position of the object set in origin_from.

origin_safe_margin

float origin_safe_margin = 0.1

If the target passes through too close to the origin than this value, time-based interpolation is used even if the target is within the angular limitations, to prevent the angular velocity from becoming too high.

primary_damp_threshold

float primary_damp_threshold

The threshold to start damping for primary_limit_angle. It provides non-linear (b-spline) interpolation, let it feel more resistance the more it rotate to the edge limit. This is useful for simulating the limits of human motion.

If 1.0, no damping is performed. If 0.0, damping is always performed.

primary_limit_angle

float primary_limit_angle

The limit angle of the primary rotation when symmetry_limitation is true, in radians.

primary_negative_damp_threshold

float primary_negative_damp_threshold

The threshold to start damping for primary_negative_limit_angle.

primary_negative_limit_angle

float primary_negative_limit_angle

The limit angle of negative side of the primary rotation when symmetry_limitation is false, in radians.

primary_positive_damp_threshold

float primary_positive_damp_threshold

The threshold to start damping for primary_positive_limit_angle.

primary_positive_limit_angle

float primary_positive_limit_angle

The limit angle of positive side of the primary rotation when symmetry_limitation is false, in radians.

primary_rotation_axis

Vector3.Axis primary_rotation_axis = 1

The axis of the first rotation. This SkeletonModifier3D works by compositing the rotation by Euler angles to prevent to rotate the forward_axis.

Note: Since LookAtModifier3D never modifies the twist when use_secondary_rotation is false and relative is true, the twist is not fixed even if use_rest_for_limitation is true.

relative

bool relative = false

The relative option. If true, the rotation is applied relative to the pose. If false, the rotation is applied relative to the rest. It means to replace the current pose with the LookAtModifier3D’s result.

secondary_damp_threshold

float secondary_damp_threshold

The threshold to start damping for secondary_limit_angle.

secondary_limit_angle

float secondary_limit_angle

The limit angle of the secondary rotation when symmetry_limitation is true, in radians.

secondary_negative_damp_threshold

float secondary_negative_damp_threshold

The threshold to start damping for secondary_negative_limit_angle.

secondary_negative_limit_angle

float secondary_negative_limit_angle

The limit angle of negative side of the secondary rotation when symmetry_limitation is false, in radians.

secondary_positive_damp_threshold

float secondary_positive_damp_threshold

The threshold to start damping for secondary_positive_limit_angle.

secondary_positive_limit_angle

float secondary_positive_limit_angle

The limit angle of positive side of the secondary rotation when symmetry_limitation is false, in radians.

symmetry_limitation

bool symmetry_limitation

If true, the limitations are spread from the bone symmetrically.

If false, the limitation can be specified separately for each side of the reference pose. In here, the reference pose is the bone pose immediately before processing this modifier.

target_node

EntityPath target_node = EntityPath("")

The EntityPath to the node that is the target for the look at modification. This node is what the modification will rotate the bone to.

transition_type

Tween.TransitionType transition_type = 0

The transition type of the time-based interpolation. See also Tween.TransitionType.

use_angle_limitation

bool use_angle_limitation = false

If true, limits the amount of rotation. For example, this helps to prevent a character’s neck from rotating 360 degrees.

Note: As with AnimationTree blending, interpolation is provided that favors Skeleton3D.get_bone_rest() or Skeleton3D.get_bone_pose() depends on the relative option. This means that interpolation does not select the shortest path in some cases.

Note: Some values for transition_type (such as Tween.TRANS_BACK, Tween.TRANS_ELASTIC, and Tween.TRANS_SPRING) may exceed the limitations. If interpolation occurs while overshooting the limitations, the result might not respect the bone rest.

use_rest_for_limitation

bool use_rest_for_limitation

If true, the angle limitation and the rotation axes are applied based on the Skeleton3D.get_bone_rest().

If false, the angle limitation is applied based on the reference pose. In here, the reference pose is the bone pose immediately before processing this modifier.

Note: The limitation is applied to the rotation computed by this modifier. If the reference pose is rotated around the same axis, the limitation behaves as if it also limits the rotation of the reference pose. A rotation that this modifier does not change, such as the twist, is not limited.

use_secondary_rotation

bool use_secondary_rotation = true

If true, provides rotation by two axes.

get_interpolation_remaining

float get_interpolation_remaining() const

Returns the remaining seconds of the time-based interpolation.

is_interpolating

bool is_interpolating() const

Returns true if time-based interpolation is running. If false, it is equivalent to get_interpolation_remaining() returning 0.0.

This is useful to determine whether a LookAtModifier3D can be removed safely.

is_target_within_limitation

bool is_target_within_limitation() const

Returns whether the target is within the angle limitations. It is useful for unsetting the target_node when the target is outside of the angle limitations.

Note: The value is updated after SkeletonModifier3D._process_modification_with_delta(). To retrieve this value correctly, we recommend using the signal SkeletonModifier3D.modification_processed.