Home>

I'm making an animation of movement and rotation,
As the animation repeats, the coordinates that are not related to the animation will gradually shift.


hierarchy

Root Object (empty game object)
 ├ Layer Object
 ├ Layer Object (copy)
     :
 └ Layer Object (copy)

Attach Animator to Root Object and execute animation
(It is an animation that flips to y=5, rotates 180 degrees, and returns to y=0.)

             0:00 0:30 0:45 1:00
position.y 0 5 5 0
rotation.z 0 0 180 180

Duplicate multiple layer objects with script and stack
I imagine an animation that turns over the aggregate (Root Object).

When I ran it, I rotated it around the bottom of the cylindrical layer as an axis and got stuck in the ground.
(If i use root motion, you will go down and down)

┌──────────────────┐ ┐
  ├──────────────────┤ │
  ├──────────────────┤<-Layer │
  ├──────────────────┤ │
──└──────────────────┘── y=0 ┴ RootObject
            ↓The result of rotating 180 degrees
──┌──────────────────┐── y=0 ┬ RootObject
  ├──────────────────┤ │
  ├──────────────────┤<-Layer │
  ├──────────────────┤ │
  └──────────────────┘ ┘

I tried to rotate it with the height of the cylinder layer/2 as the rotation axis (Positioon.y of Root Object), but it doesn't work.

h--┌──────────────────┐
     │ │ │
h/2--│------------------│--- ┴ RootObject(0,h/2,0)
     ├──────────────────┤
   ──└──────────────────┘── y=0 LayerObject (lowest plane) (0,-h/2,0)

LayerObject Scale.y = h (overall height)/number of layers/2 (cylinder object height)


Create an object by setting the number of layers and height h
I want to be able to animate,

  • Without root motion
    RootObject.position.y=0
    → Rotate around the ground and slip into the ground
    RootObject.position.y=h/2
    → When changing the height and the number of layers, the height shifts at the start of the animation and it floats from the ground (the coordinates of the object are ignored and the coordinates are set in the animation).
  • With root motion
    Even if you change the height or the number of layers, the height at the start is y=0,
    Goes to unexpected coordinates at the end of the animation
    (The x coordinate has changed for some reason, and the y coordinate is getting more and more embedded in the ground)

How can I make it return to y=0 after doing the flip animation?

  • Answer # 1

    The coordinates set in the animation are local coordinates.
    SoRootObject(0,h/2,0)As, attach animation to RootObject.
    Then create a parent object of RootObject.
    If the height of LayerObjects and the number of layers are changed, raise the height of this parent object.
    Since it is "the height of the parent object + the height specified in the animation", it will probably work normally.

    Or
    It may be easier to use the library that can play moving animation from scripts such as iTween and calculate the height before playing.
    Check out the various types of libraries available.

  • Answer # 2

    When I ran it, I rotated it around the bottom of the cylindrical layer as an axis and got stuck in the ground.

    However, I thought that it was natural because I rotated it around the RootObject, and I was not sure what the problem was. I would like you to take a gif video or something and paste it.
    If the coordinates are fixed without root motion, you can make an animation that "I want you to move like this", right? It is easy to understand the ideal/reality if the animation of the problem behavior is lined up with the expected behavior.

    The videos are much easier to convey because you can ask questions in a shorter time than you explain hard in the text.