Attention: Here be dragons (unstable version)
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Redot.
Checking the stable version of the documentation...
LookAtModifier3D
Inherits: SkeletonModifier3D < Node3D < Node < Object
The SkeletonModifier3D rotates a bone to look a target.
Description
This SkeletonModifier3D rotates a bone to look a target. This is helpful for moving 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
|
||
|
||
|
||
|
||
|
||
|
||
|
||
Vector3.Axis |
|
|
|
||
|
||
|
||
|
Methods
get_interpolation_remaining() const |
|
is_interpolating() const |
|
is_target_within_limitation() const |
Enumerations
enum BoneAxis: 🔗
BoneAxis BONE_AXIS_PLUS_X = 0
Enumerated value for the +X axis.
BoneAxis BONE_AXIS_MINUS_X = 1
Enumerated value for the -X axis.
BoneAxis BONE_AXIS_PLUS_Y = 2
Enumerated value for the +Y axis.
BoneAxis BONE_AXIS_MINUS_Y = 3
Enumerated value for the -Y axis.
BoneAxis BONE_AXIS_PLUS_Z = 4
Enumerated value for the +Z axis.
BoneAxis BONE_AXIS_MINUS_Z = 5
Enumerated value for the -Z axis.
enum OriginFrom: 🔗
OriginFrom ORIGIN_FROM_SELF = 0
The bone rest position of the bone specified in bone is used as origin.
OriginFrom 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.
OriginFrom ORIGIN_FROM_EXTERNAL_NODE = 2
The global position of the Node3D 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.
Property Descriptions
The bone index of the Skeleton3D that the modification will operate on.
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.
The ease type of the time-based interpolation. See also EaseType.
The forward axis of the bone. This SkeletonModifier3D modifies the bone so that this axis points toward the target_node.
If origin_from is ORIGIN_FROM_SPECIFIC_BONE, the bone global pose position specified for this is used as origin.
NodePath origin_external_node 🔗
If origin_from is ORIGIN_FROM_EXTERNAL_NODE, the global position of the Node3D specified for this is used as origin.
OriginFrom origin_from = 0
🔗
void set_origin_from(value: OriginFrom)
OriginFrom get_origin_from()
This value determines from what origin is retrieved for use in the calculation of the forward vector.
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.
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.
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.
The limit angle of the primary rotation when symmetry_limitation is true
.
float primary_negative_damp_threshold 🔗
The threshold to start damping for primary_negative_limit_angle.
float primary_negative_limit_angle 🔗
The limit angle of negative side of the primary rotation when symmetry_limitation is false
.
float primary_positive_damp_threshold 🔗
The threshold to start damping for primary_positive_limit_angle.
float primary_positive_limit_angle 🔗
The limit angle of positive side of the primary rotation when symmetry_limitation is false
.
Vector3.Axis primary_rotation_axis = 1
🔗
void set_primary_rotation_axis(value: Vector3.Axis)
Vector3.Axis get_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.
float secondary_damp_threshold 🔗
The threshold to start damping for secondary_limit_angle.
The limit angle of the secondary rotation when symmetry_limitation is true
.
float secondary_negative_damp_threshold 🔗
void set_secondary_negative_damp_threshold(value: float)
float get_secondary_negative_damp_threshold()
The threshold to start damping for secondary_negative_limit_angle.
float secondary_negative_limit_angle 🔗
The limit angle of negative side of the secondary rotation when symmetry_limitation is false
.
float secondary_positive_damp_threshold 🔗
void set_secondary_positive_damp_threshold(value: float)
float get_secondary_positive_damp_threshold()
The threshold to start damping for secondary_positive_limit_angle.
float secondary_positive_limit_angle 🔗
The limit angle of positive side of the secondary rotation when symmetry_limitation is false
.
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.
NodePath target_node = NodePath("")
🔗
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.
TransitionType transition_type = 0
🔗
void set_transition_type(value: TransitionType)
TransitionType get_transition_type()
The transition type of the time-based interpolation. See also TransitionType.
bool use_angle_limitation = false
🔗
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.
bool use_secondary_rotation = true
🔗
If true
, provides rotation by two axes.
Method Descriptions
float get_interpolation_remaining() const 🔗
Returns the remaining seconds of the time-based interpolation.
bool is_interpolating() 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_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. To retrieve this value correctly, we recommend using the signal SkeletonModifier3D.modification_processed.