diff options
Diffstat (limited to 'scene/animation/root_motion_view.cpp')
-rw-r--r-- | scene/animation/root_motion_view.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/animation/root_motion_view.cpp b/scene/animation/root_motion_view.cpp index e6b258df3e..fc758b9456 100644 --- a/scene/animation/root_motion_view.cpp +++ b/scene/animation/root_motion_view.cpp @@ -80,13 +80,15 @@ bool RootMotionView::get_zero_y() const { void RootMotionView::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { - immediate_material = StandardMaterial3D::get_material_for_2d(false, true, false, false, false); + immediate_material = StandardMaterial3D::get_material_for_2d(false, BaseMaterial3D::TRANSPARENCY_ALPHA, false); + first = true; } break; case NOTIFICATION_INTERNAL_PROCESS: case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { Transform3D transform; + Basis diff; if (has_node(path)) { Node *node = get_node(path); @@ -102,9 +104,9 @@ void RootMotionView::_notification(int p_what) { set_process_internal(true); set_physics_process_internal(false); } - transform.origin = tree->get_root_motion_position(); transform.basis = tree->get_root_motion_rotation(); // Scale is meaningless. + diff = tree->get_root_motion_rotation_accumulator(); } } @@ -114,8 +116,10 @@ void RootMotionView::_notification(int p_what) { first = false; - accumulated.origin += transform.origin; accumulated.basis *= transform.basis; + transform.origin = (diff.inverse() * accumulated.basis).xform(transform.origin); + accumulated.origin += transform.origin; + accumulated.origin.x = Math::fposmod(accumulated.origin.x, cell_size); if (zero_y) { accumulated.origin.y = 0; |