Rotation Animation Not working

After Instantiate I plan to Rotate Animation

if (prefabToSpawn && hasPlaced === 0) {

      const {worldPosition} = e.data as any

      const newInstance = world.createEntity(prefabToSpawn)

      const randomScale = Math.random() \* (maxScale - minScale) + minScale



      ecs.Position.set(world, newInstance, worldPosition)



      ecs.ScaleAnimation.set(world, newInstance, {

        fromX: 0,

        fromY: 0,

        fromZ: 0,

        toX: randomScale,

        toY: randomScale,

        toZ: randomScale,

        duration: 400,

        loop: false,

        easeOut: true,

        easingFunction: 'Quadratic',

      })



      **ecs.RotateAnimation.set(world, newInstance, {**

        **fromX: 0,**

        **fromY: 0,**

        **fromZ: 0,**

        **toX: 0,**

        **toY: 360,                  *// spin around Y axis***

        **toZ: 0,**

        **duration: 2000,**

        **loop: true,                *// 🔁 keep spinning***

        **easeOut: false,**

        **easingFunction: 'Linear',  *// smooth constant spin***

      **})

this is script i can use So Rotation not working**

Hi, welcome to the forum!

The reason it’s “not working” is because by default the rotationAnimation will choose the shortest path to reach the target. In this case the shortest path to a full rotation is to not actually move at all.

The solution to this is to add shortestPath: false to your component schema. :slight_smile: