Animation glitch: instantly jumps to the location at the end of the animation on frame 1

Recommended Posts

In this code here, on the 1st frame of the animation the mesh being animated instantly jumps to the location at the end of the animation, then the next frame it goes back to frame2 at the interpolated location. Any ideas?


       let unit = selectedUnits[i]

      // use pythagoras to work out the realtive speed for the units to arrive at roughly the same time
      let distance = Math.sqrt(Math.pow(pickResult.x - unit.mesh.position.x, 2)
        + Math.pow(pickResult.z - unit.mesh.position.z, 2))
      let framesNeeded = Math.round((distance / common.MEDIUM_SPEED) * common.ANIMATIONS_FPS)
      // console.log('dist: ' + distance + ' frames' + framesNeeded)

      let animationBezierTorus = new BABYLON.Animation('animationCore', 'position',
      let keysBezierTorus = []
      keysBezierTorus.push({ frame: 0, value: unit.mesh.position })

        frame: framesNeeded,
        value: unit.mesh.position = formation[i]
      this.scene.beginAnimation(unit.mesh, 0, framesNeeded, true) // todo move animation to server side

You can see this effect by trying to move any of the blue spheres:

Share this post

Link to post
Share on other sites

Heya N!  Sorry for the slow replies.  Is there ANY chance that you could reproduce this issue... in a playground?  Or, how about creating a version with no laser and stripped-down core, common, and Game object?

Let me make sure I have the symptom correct.  Click-on any purple sphere.  Then click somewhere on ground grid.  There is a "flash-glitch" that happens as animation starts, right?

It is ONLY happening on the green box, yes?

What does a console dump of green box anim keys LOOK LIKE (dumped just before anim start)?  They look correct?

Anyway, we have now "bumped" the topic back onto forum page 1.  :)  Not easy to troubleshoot... kind of big. Simplify and de-webpack if you can. I'll keep thinkin'.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.