Jump to content

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


Nikos123
 Share

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',
        common.ANIMATIONS_FPS,
        BABYLON.Animation.ANIMATIONTYPE_VECTOR3,
        BABYLON.Animation.ANIMATIONLOOPMODE_CONSTANT)
      let keysBezierTorus = []
      keysBezierTorus.push({ frame: 0, value: unit.mesh.position })

      keysBezierTorus.push({
        frame: framesNeeded,
        value: unit.mesh.position = formation[i]
      })
      animationBezierTorus.setKeys(keysBezierTorus)
      unit.mesh.animations.push(animationBezierTorus)
      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: http://quantuminformation.github.io/Density-Wars/

Link to comment
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'.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...