Skip to content

Commit

Permalink
Implement LookAtModifier3D
Browse files Browse the repository at this point in the history
  • Loading branch information
TokageItLab committed Oct 23, 2024
1 parent 80f0b33 commit ea980b9
Show file tree
Hide file tree
Showing 5 changed files with 647 additions and 0 deletions.
75 changes: 75 additions & 0 deletions doc/classes/LookAtModifier3D.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="LookAtModifier3D" inherits="SkeletonModifier3D" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
</brief_description>
<description>
This [SkeletonModifier3D] rotates a bone to look a target. This is extremely 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.
</description>
<tutorials>
</tutorials>
<members>
<member name="bone" type="int" setter="set_bone" getter="get_bone" default="0">
The bone index of the [Skeleton3D] that the modification will operate on.
</member>
<member name="duration" type="float" setter="set_duration" getter="get_duration" default="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
</member>
<member name="ease_type" type="int" setter="set_ease_type" getter="get_ease_type" enum="Tween.EaseType" default="0">
The ease type of the time-based interpolation. See also [enum Tween.EaseType].
</member>
<member name="forward_axis" type="int" setter="set_forward_axis" getter="get_forward_axis" enum="LookAtModifier3D.BoneAxis" default="4">
The forward axis of the bone. This [SkeletonModifier3D] modifies the bone so that this axis points toward the [member target_node].
</member>
<member name="primary_damp_threshold" type="float" setter="set_primary_damp_threshold" getter="get_primary_damp_threshold">
The threshold to start damping for [member primary_limit_angle]. It provides non-linear(logarithmic) 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 [code]1.0[/code], no damping is performed. If [code]0.0[/code], damping is performed always.
</member>
<member name="primary_limit_angle" type="float" setter="set_primary_limit_angle" getter="get_primary_limit_angle">
The limit angle of the secondary rotation.
</member>
<member name="primary_rotation_axis" type="int" setter="set_primary_rotation_axis" getter="get_primary_rotation_axis" enum="Vector3.Axis" default="1">
The axis of the first rotation. This [SkeletonModifier3D] works by compositing the rotation by Euler angles to prevent to rotate the [member forward_axis].
</member>
<member name="secondary_damp_threshold" type="float" setter="set_secondary_damp_threshold" getter="get_secondary_damp_threshold">
The threshold to start damping for [member secondary_limit_angle].
</member>
<member name="secondary_limit_angle" type="float" setter="set_secondary_limit_angle" getter="get_secondary_limit_angle">
The limit angle of the secondary rotation.
</member>
<member name="target_node" type="NodePath" setter="set_target_node" getter="get_target_node" default="NodePath(&quot;&quot;)">
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.
</member>
<member name="transition_type" type="int" setter="set_transition_type" getter="get_transition_type" enum="Tween.TransitionType" default="0">
The transition type of the time-based interpolation. See also [enum Tween.TransitionType].
</member>
<member name="use_angle_limitation" type="bool" setter="set_use_angle_limitation" getter="is_using_angle_limitation" default="false">
If [code]true[/code], limits the degree of rotation. This helps prevent the character's neck from rotating 360 degrees.
[b]Note:[/b] As with [AnimationTree] blending, interpolation is provided that favors [method Skeleton3D.get_bone_rest]. This means that interpolation does not select the shortest path in some cases.
</member>
<member name="use_secondary_rotation" type="bool" setter="set_use_secondary_rotation" getter="is_using_secondary_rotation" default="true">
If [code]true[/code], provides rotation by two axes.
</member>
</members>
<constants>
<constant name="BONE_AXIS_PLUS_X" value="0" enum="BoneAxis">
Enumerated value for the +X axis.
</constant>
<constant name="BONE_AXIS_MINUS_X" value="1" enum="BoneAxis">
Enumerated value for the -X axis.
</constant>
<constant name="BONE_AXIS_PLUS_Y" value="2" enum="BoneAxis">
Enumerated value for the +Y axis.
</constant>
<constant name="BONE_AXIS_MINUS_Y" value="3" enum="BoneAxis">
Enumerated value for the -Y axis.
</constant>
<constant name="BONE_AXIS_PLUS_Z" value="4" enum="BoneAxis">
Enumerated value for the +Z axis.
</constant>
<constant name="BONE_AXIS_MINUS_Z" value="5" enum="BoneAxis">
Enumerated value for the -Z axis.
</constant>
</constants>
</class>
1 change: 1 addition & 0 deletions editor/icons/LookAtModifier3D.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit ea980b9

Please sign in to comment.