Class LookAtModifier3D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public class LookAtModifier3D : SkeletonModifier3D, IDisposable
- Inheritance
-
LookAtModifier3D
- Implements
- Inherited Members
Constructors
LookAtModifier3D()
public LookAtModifier3D()
Properties
Bone
Index of the BoneName in the parent Skeleton3D.
public int Bone { get; set; }
Property Value
BoneName
The bone name of the Skeleton3D that the modification will operate on.
public string BoneName { get; set; }
Property Value
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 ForwardAxis and PrimaryRotationAxis.
public float Duration { get; set; }
Property Value
EaseType
The ease type of the time-based interpolation. See also Tween.EaseType.
public Tween.EaseType EaseType { get; set; }
Property Value
ForwardAxis
The forward axis of the bone. This SkeletonModifier3D modifies the bone so that this axis points toward the TargetNode.
public SkeletonModifier3D.BoneAxis ForwardAxis { get; set; }
Property Value
OriginBone
Index of the OriginBoneName in the parent Skeleton3D.
public int OriginBone { get; set; }
Property Value
OriginBoneName
If OriginFrom is SpecificBone, the bone global pose position specified for this is used as origin.
public string OriginBoneName { get; set; }
Property Value
OriginExternalNode
If OriginFrom is ExternalNode, the global position of the Node3D specified for this is used as origin.
public NodePath OriginExternalNode { get; set; }
Property Value
OriginFrom
This value determines from what origin is retrieved for use in the calculation of the forward vector.
public LookAtModifier3D.OriginFromEnum OriginFrom { get; set; }
Property Value
OriginOffset
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 OriginFrom.
public Vector3 OriginOffset { get; set; }
Property Value
OriginSafeMargin
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.
public float OriginSafeMargin { get; set; }
Property Value
PrimaryDampThreshold
The threshold to start damping for PrimaryLimitAngle. 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.
public float PrimaryDampThreshold { get; set; }
Property Value
PrimaryLimitAngle
The limit angle of the primary rotation when SymmetryLimitation is true.
public float PrimaryLimitAngle { get; set; }
Property Value
PrimaryNegativeDampThreshold
The threshold to start damping for PrimaryNegativeLimitAngle.
public float PrimaryNegativeDampThreshold { get; set; }
Property Value
PrimaryNegativeLimitAngle
The limit angle of negative side of the primary rotation when SymmetryLimitation is false.
public float PrimaryNegativeLimitAngle { get; set; }
Property Value
PrimaryPositiveDampThreshold
The threshold to start damping for PrimaryPositiveLimitAngle.
public float PrimaryPositiveDampThreshold { get; set; }
Property Value
PrimaryPositiveLimitAngle
The limit angle of positive side of the primary rotation when SymmetryLimitation is false.
public float PrimaryPositiveLimitAngle { get; set; }
Property Value
PrimaryRotationAxis
The axis of the first rotation. This SkeletonModifier3D works by compositing the rotation by Euler angles to prevent to rotate the ForwardAxis.
public Vector3.Axis PrimaryRotationAxis { get; set; }
Property Value
SecondaryDampThreshold
The threshold to start damping for SecondaryLimitAngle.
public float SecondaryDampThreshold { get; set; }
Property Value
SecondaryLimitAngle
The limit angle of the secondary rotation when SymmetryLimitation is true.
public float SecondaryLimitAngle { get; set; }
Property Value
SecondaryNegativeDampThreshold
The threshold to start damping for SecondaryNegativeLimitAngle.
public float SecondaryNegativeDampThreshold { get; set; }
Property Value
SecondaryNegativeLimitAngle
The limit angle of negative side of the secondary rotation when SymmetryLimitation is false.
public float SecondaryNegativeLimitAngle { get; set; }
Property Value
SecondaryPositiveDampThreshold
The threshold to start damping for SecondaryPositiveLimitAngle.
public float SecondaryPositiveDampThreshold { get; set; }
Property Value
SecondaryPositiveLimitAngle
The limit angle of positive side of the secondary rotation when SymmetryLimitation is false.
public float SecondaryPositiveLimitAngle { get; set; }
Property Value
SymmetryLimitation
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.
public bool SymmetryLimitation { get; set; }
Property Value
TargetNode
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.
public NodePath TargetNode { get; set; }
Property Value
TransitionType
The transition type of the time-based interpolation. See also Tween.TransitionType.
public Tween.TransitionType TransitionType { get; set; }
Property Value
UseAngleLimitation
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 GetBoneRest(int). This means that interpolation does not select the shortest path in some cases.
Note: Some TransitionType 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.
public bool UseAngleLimitation { get; set; }
Property Value
UseSecondaryRotation
If true, provides rotation by two axes.
public bool UseSecondaryRotation { get; set; }
Property Value
Methods
GetInterpolationRemaining()
Returns the remaining seconds of the time-based interpolation.
public float GetInterpolationRemaining()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsInterpolating()
Returns whether the time-based interpolation is running or not. If true, it is equivalent to GetInterpolationRemaining() being 0
.
This is useful to determine whether a LookAtModifier3D can be removed safely.
public bool IsInterpolating()
Returns
IsTargetWithinLimitation()
Returns whether the target is within the angle limitations. It is useful for unsetting the TargetNode when the target is outside of the angle limitations.
Note: The value is updated after _ProcessModification(). To retrieve this value correctly, we recommend using the signal ModificationProcessed.
public bool IsTargetWithinLimitation()