Table of Contents

Class LookAtModifier3D

The LookAtModifier3D rotates a bone to look at a target.

Inheritance
LookAtModifier3D

Remarks

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.

Properties

bone

Index of the bone_name in the parent Skeleton3D.

var bone : int = -1

Property Value

int

Remarks

  • void set_bone(int value)
  • int get_bone

bone_name

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

var bone_name : String = ""

Property Value

String

Remarks

duration

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.

var duration : float = 0.0

Property Value

float

Remarks

  • void set_duration(float value)
  • float get_duration

ease_type

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

var ease_type : int = 0

Property Value

int

Remarks

  • void set_ease_type(int value)
  • int get_ease_type

forward_axis

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

var forward_axis : int = 4

Property Value

int

Remarks

  • void set_forward_axis(int value)
  • int get_forward_axis

origin_bone

Index of the origin_bone_name in the parent Skeleton3D.

var origin_bone : int

Property Value

int

Remarks

  • void set_origin_bone(int value)
  • int get_origin_bone

origin_bone_name

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

var origin_bone_name : String

Property Value

String

Remarks

  • void set_origin_bone_name(String value)
  • String get_origin_bone_name

origin_external_node

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

var origin_external_node : NodePath

Property Value

NodePath

Remarks

  • void set_origin_external_node(NodePath value)
  • NodePath get_origin_external_node

origin_from

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

var origin_from : int = 0

Property Value

int

Remarks

  • void set_origin_from(int value)
  • int get_origin_from

origin_offset

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.

var origin_offset : Vector3 = Vector3(0, 0, 0)

Property Value

Vector3

Remarks

origin_safe_margin

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.

var origin_safe_margin : float = 0.1

Property Value

float

Remarks

  • void set_origin_safe_margin(float value)
  • float get_origin_safe_margin

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.

var primary_damp_threshold : float

Property Value

float

Remarks

  • void set_primary_damp_threshold(float value)
  • float get_primary_damp_threshold

primary_limit_angle

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

var primary_limit_angle : float

Property Value

float

Remarks

  • void set_primary_limit_angle(float value)
  • float get_primary_limit_angle

primary_negative_damp_threshold

The threshold to start damping for primary_negative_limit_angle.

var primary_negative_damp_threshold : float

Property Value

float

Remarks

  • void set_primary_negative_damp_threshold(float value)
  • float get_primary_negative_damp_threshold

primary_negative_limit_angle

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

var primary_negative_limit_angle : float

Property Value

float

Remarks

  • void set_primary_negative_limit_angle(float value)
  • float get_primary_negative_limit_angle

primary_positive_damp_threshold

The threshold to start damping for primary_positive_limit_angle.

var primary_positive_damp_threshold : float

Property Value

float

Remarks

  • void set_primary_positive_damp_threshold(float value)
  • float get_primary_positive_damp_threshold

primary_positive_limit_angle

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

var primary_positive_limit_angle : float

Property Value

float

Remarks

  • void set_primary_positive_limit_angle(float value)
  • float get_primary_positive_limit_angle

primary_rotation_axis

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

var primary_rotation_axis : int = 1

Property Value

int

Remarks

  • void set_primary_rotation_axis(int value)
  • int get_primary_rotation_axis

secondary_damp_threshold

The threshold to start damping for secondary_limit_angle.

var secondary_damp_threshold : float

Property Value

float

Remarks

  • void set_secondary_damp_threshold(float value)
  • float get_secondary_damp_threshold

secondary_limit_angle

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

var secondary_limit_angle : float

Property Value

float

Remarks

  • void set_secondary_limit_angle(float value)
  • float get_secondary_limit_angle

secondary_negative_damp_threshold

The threshold to start damping for secondary_negative_limit_angle.

var secondary_negative_damp_threshold : float

Property Value

float

Remarks

  • void set_secondary_negative_damp_threshold(float value)
  • float get_secondary_negative_damp_threshold

secondary_negative_limit_angle

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

var secondary_negative_limit_angle : float

Property Value

float

Remarks

  • void set_secondary_negative_limit_angle(float value)
  • float get_secondary_negative_limit_angle

secondary_positive_damp_threshold

The threshold to start damping for secondary_positive_limit_angle.

var secondary_positive_damp_threshold : float

Property Value

float

Remarks

  • void set_secondary_positive_damp_threshold(float value)
  • float get_secondary_positive_damp_threshold

secondary_positive_limit_angle

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

var secondary_positive_limit_angle : float

Property Value

float

Remarks

  • void set_secondary_positive_limit_angle(float value)
  • float get_secondary_positive_limit_angle

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 bone rest.

var symmetry_limitation : bool

Property Value

bool

Remarks

  • void set_symmetry_limitation(bool value)
  • bool is_limitation_symmetry

target_node

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

var target_node : NodePath = NodePath("")

Property Value

NodePath

Remarks

transition_type

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

var transition_type : int = 0

Property Value

int

Remarks

  • void set_transition_type(int value)
  • int get_transition_type

use_angle_limitation

If true, limits the degree of rotation. This helps prevent the character's neck from rotating 360 degrees.

Note: As with AnimationTree blending, interpolation is provided that favors Skeleton3D.get_bone_rest. This means that interpolation does not select the shortest path in some cases.

Note: Some transition_type may exceed the limitations (e.g. Back, Elastic, and Spring). If interpolation occurs while overshooting the limitations, the result might possibly not respect the bone rest.

var use_angle_limitation : bool = false

Property Value

bool

Remarks

  • void set_use_angle_limitation(bool value)
  • bool is_using_angle_limitation

use_secondary_rotation

If true, provides rotation by two axes.

var use_secondary_rotation : bool = true

Property Value

bool

Remarks

  • void set_use_secondary_rotation(bool value)
  • bool is_using_secondary_rotation

Methods

get_interpolation_remaining

Qualifiers: const

Returns the remaining seconds of the time-based interpolation.

float get_interpolation_remaining

is_interpolating

Qualifiers: const

Returns whether the time-based interpolation is running or not. If true, it is equivalent to get_interpolation_remaining being 0.

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

bool is_interpolating

is_target_within_limitation

Qualifiers: 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 _process_modification. To retrieve this value correctly, we recommend using the signal modification_processed.

bool is_target_within_limitation