Jump to content

Keep Same Position On Animation loop


MackeyK24
 Share

Recommended Posts

Hey guys... I got yet another one...

 

I am currently using an animation to control a curve... List call that animPosition... I encode root transform positions into the animation and the animation updates

the animPosition.xyz from the BabylonAnimationKey... I use this to move the character... works great except my logic for when the animation loops (even with relative cycle mode)...

Basically if the animation controlling the animPosition rotates the chaterter 0 to 90 degrees... when the animation loops the values are the same as before it just loops to when replayed it SNAPS back to 0 and goes from 0 to 90... again...

What I need is to offset so that when the animation loops a second time this values in the animation 'Contribute' to the move of the character movement so when looping that animation with the sample numbers again a second time will make go from 90  - 180 and so on... so that values coming from the root motion accumulated (I guess):

 

My animation state machine exposes that 'animated animPosition' as rootPosition and calculates the delta from the lastPostion... and it is exposed as:

getDeltaPosition... that little bit off delta position is then use to move the character... _chacter.move() really call physicsImposter.setLinearVelocity

anyways this is how I am taking the 'delta from the last position and using that as movement:

if (this._animator != null) {
    var deltaTime:number = this.manager.deltaTime;          
    var deltaPosition:BABYLON.Vector3 = this._animator.getDeltaPosition();
    var rootPosition:BABYLON.Vector3 = this._animator.getRootPosition();
    if (this._character != null) {
        this._inputVelocity.x = (deltaPosition.x * this.moveSpeed) / deltaTime;
        this._inputVelocity.y = 0.0;
        this._inputVelocity.z = (deltaPosition.z * this.moveSpeed) / deltaTime;

        var jumped:boolean = (this.manager.getKeyInput(this.keyboardJump) || this.manager.getButtonInput(this.buttonJump));
        if (jumped === true) this._inputVelocity.y = this.jumpForce;

        this._character.move(this._inputVelocity, jumped);
    }
}

 

that moves everything great UNTIL the animation loop that resets the main animPosition (that delta is calculated from) to the values in the animation at starting frame... lets say for simple sake that is facing forward with no rotation.. call it 0... when the animation stops its at 90... the loop reset back to zero INSTEAD of continuing to turn to 180 (which is what I want)

I know that a mouth full :)

But if can figure this last part out... I will have root motion working for BabylonJS...

Note: If anybody wants to help with issue (Animation State) or any of the other small issues I have outstanding... LET ME KNOW... I will send you a copy of the BabylonJS Toolkit Version 3.1 Beta and we can work together...

I would love to be able to work with (and actually talk to) someone... We can GOTOMeeting and show each other code pieces and work on it together....

Outstanding Issues:

- Animation System (including Blend Trees if can be done in BabylonJS)

- Terrain System... Need to be able to use a Texture Atlas in GLSL Shader... right now the only way I know is to use 'fract' call... but that LEAVES EDGE SEEMS

- LDR Skyboxes - you can't really use a HDR for the whole sky... (maybe for just HDR reflections which should be a MUCH smaller scaled down version of a full panorama HDR file)... So I created a HDR to LDR Tone Mapping Tool... To use it I need a babylonLDRCubeTexture.ts to be create that work like HDRCubeTexture EXPECT use the ALREDY encoded LDR Tone Mapped pixels as a JPG or PNG.

Particle System - Fine tune my ShurikenParticleSystem class I created to give a Shurken time based particle system ike the used in Unity... I got everything going except some 'Update-Over-Time' functionally I need to give additional 'Velocity' to the 'AGED' particle over time... NOT just adjust the 'EMITTER POWER' which starts the particle on it way... but use a curve to control the velocity of the particle over time... I think it uses a property called 'Age' for that... So let say 5 seconds into the particle system playing I was to start giving a velocity that might adjust a partialce that Is going start up... to start going left... But not at the emitter... once the particle has left the emitter and is 5 sec into its life... or what ever the curve is keyed to.

Anyways... Let me know if anybody can help with those outstanding issues I need to clear up before release the version 3.1 of the BabylonJS Toolkit :)

 

Link to comment
Share on other sites

I have a PG that continuously rotates 90° as separate animations, but it's not likely what you are after.  The idea is that I recreate the animation taking current rotation and increase from there.  I think you said you were baking all your animations from the start together, so what if you had all 4 animations ({0-90},{90-180},{180-270},{270-0} and just ran the 1/4 that you needed?

Here is my PG - a keen eye will notice that it's only working because of the timing as the plane physics impostors are sleeping during rotation, so that's why I think may not be helpful, but at least you can see one way.

http://www.babylonjs-playground.com/#58SJXF#3

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...