Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement LookAtModifier3D #98446

Merged
merged 1 commit into from
Nov 12, 2024
Merged

Conversation

TokageItLab
Copy link
Member

@TokageItLab TokageItLab commented Oct 23, 2024

Add a LookAtModifier3D. This modifier allows you to specify a forward axis and provides a two-axis Euler rotation to prevent roll the forward axis.

lkat001.mp4

Features

Time-based interpolation

When the character changes the lock-on target, it will take a certain amount of time to rotate instead of immediately rotating its head. The time-based interpolation uses a tween, so several transition/easing types can be selected.

lkat002.mp4

Angle limitation

This option allows you to prevent the character's neck from rotating 360 degrees. The limitation means that half angle of the limit from the bone rest is the range of motion. Both symmetrical and non-symmetrical limitations are supported.

Also, when this option is enabled, time-based interpolation will provide rest-aware rotation, similar to AnimationTree blending. This means that in some cases the shortest path will not be selected to prevent bones from penetrating through the body. See also for-better-blending.

In addition, if the target moves outside of these limits, axis flipping may occur, where time-based interpolation is used.

lkat003.mp4

Non-linear damping

To prevent abrupt changes in angular velocity at the edge of the angular limit, the option is to start non-linear(b-spline) damping from the threshold value.

This helps simulate natural human motion.

lkat004.mp4

Origin setting

There are some cases where multiple bones need to always point in the same direction, such as the eyes.

For example, angle limitation may cause bone to flip outside their limits, which is not good because only one of the eyes will move significantly. Setting an arbitrary origin helps to solve this problem.

Origin from

For example, To solve the above problem, it is possible to set the head to origin for eyes. Or you can use BoneAttachment or parent-child Node3D.

image

Offset

The problem can be addressed by matching the origin by offset without any external node or bone as well.

lkat005.mp4

@TokageItLab TokageItLab added this to the 4.4 milestone Oct 23, 2024
@TokageItLab TokageItLab requested review from a team as code owners October 23, 2024 03:26
@TokageItLab TokageItLab force-pushed the look-at-modifier branch 2 times, most recently from 2d49ab5 to e28301c Compare October 23, 2024 03:31
@TokageItLab TokageItLab requested a review from a team October 23, 2024 03:54
@TokageItLab TokageItLab force-pushed the look-at-modifier branch 18 times, most recently from 34a2b00 to 84d3d88 Compare October 23, 2024 20:45
@TokageItLab TokageItLab force-pushed the look-at-modifier branch 6 times, most recently from 5971a16 to 51d0b43 Compare October 27, 2024 13:23
@TokageItLab
Copy link
Member Author

TokageItLab commented Oct 27, 2024

Added:

  • A configuration warning when the forward axis and rotation axis are parallel to the node (I think we should migrate to property warning later)
  • Some comments to the code
  • Some Notes to the document

@TokageItLab TokageItLab force-pushed the look-at-modifier branch 7 times, most recently from dd3d3e2 to 4a2c99a Compare October 30, 2024 17:31
@SaracenOne SaracenOne self-assigned this Nov 10, 2024
Copy link
Member

@SaracenOne SaracenOne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed and tested during the Animation Meeting and everyone seems satisfied that it works and adds broadly useful functionality. 👍

It is also worth noting that it largely follows the spec put forward by the VRM consortium https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_vrm-1.0/lookAt.md

scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
doc/classes/LookAtModifier3D.xml Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.cpp Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
scene/3d/look_at_modifier_3d.h Outdated Show resolved Hide resolved
@TokageItLab TokageItLab force-pushed the look-at-modifier branch 2 times, most recently from c327fac to 78c3f53 Compare November 11, 2024 20:00
@Repiteo Repiteo merged commit 9995c3e into godotengine:master Nov 12, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Nov 12, 2024

Thanks!

@JekSun97
Copy link
Contributor

@TokageItLab Thanks, I've been waiting for modifiers for skeletons for a long time!
I would like to know if there will be other modifiers in 4.4? If so, what will be their purpose?

@fire
Copy link
Member

fire commented Nov 21, 2024

@JekSun97 Please review and contribute to the discussion here godotengine/godot-proposals#9885 (Needed Skeleton Modifiers)

@crei0
Copy link
Contributor

crei0 commented Nov 22, 2024

I think there's a typo on the Documentation data doc/classes/LookAtModifier3D.xml, it's saying in some locations SkeletonModifier3D instead of the correct LookAtModifier3D

This is visible at the documentation page at https://docs.godotengine.org/en/latest/classes/class_lookatmodifier3d.html

Location 1:
The SkeletonModifier3D rotates a bone to look a target.
it should say
The LookAtModifier3D rotates a bone to look a target.

Location 2:
This SkeletonModifier3D rotates a bone to look a target. [...]
it should say
This LookAtModifier3D rotates a bone to look a target. [...]

And on Create a new node window on the tooltip and on the description section
image

PS: I've created an Issue for this at #99532

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

7 participants