Why the game clock can't fulfill my animation needs?

Recommended Posts

I am right now using the high performance counters, and the speed of the agent is 5 m/s
If the distance is larger than 10meters, it is very slowy...

l_transform->m_MotionInfo->m_fS += ((l_transform->m_MotionInfo->m_fSpeed
/ l_transform->m_MotionInfo->m_fDist) * m_fElapsedTime);

Way too slooooooow..! But if I multiply it by a factor of 10, it is crazily fast...

The agent stays at some waypoint, stands there for a while, then go to the next waypoint, I don't know why it waits


	fS is 0.0593374
fS is 0.0595481
fS is 0.0597553
fS is 0.0599701
fS is 0.0601748
fS is 0.0603783
fS is 0.0605615
fS is 0.0607767
fS is 0.060987
fS is 0.061208
fS is 0.0613958
fS is 0.0616221
fS is 0.0618306
fS is 0.0620498
fS is 0.0622616
fS is 0.0624997
fS is 0.0626887
fS is 0.0629133
fS is 0.0631273
fS is 0.0633261
fS is 0.0635207
fS is 0.0637409
fS is 0.0639357
fS is 0.0641703
fS is 0.064362
fS is 0.064564
fS is 0.0647534
fS is 0.0650121
fS is 0.065251
fS is 0.0654732
fS is 0.0656744
fS is 0.0659465
fS is 0.0661739




Edited by lucky6969b

Share this post

Link to post
Share on other sites

That solves nicely...



	if(l_transform->m_MotionInfo->m_fS < 1.0f)
        l_transform->m_MotionInfo->m_fS += ((l_transform->m_MotionInfo->m_fSpeed / l_transform->m_MotionInfo->m_fDist) * m_fElapsedTime);
            l_transform->m_MotionInfo->m_vEndPos, l_transform->m_MotionInfo->m_fS));
	        float x = l_transform->m_MotionInfo->m_vEndPos.x - l_transform->m_MotionInfo->m_vStartPos.x;
        float z = l_transform->m_MotionInfo->m_vEndPos.z - l_transform->m_MotionInfo->m_vStartPos.z;
        float fNewDir = atan2f(-x, -z);                
	         l_transform->setRotation(D3DXVECTOR3(fNewDir, 0.0f, 0.0f));
    // upon reached destination
    else if(l_transform->m_MotionInfo->m_fS > 1.0f)
        l_transform->m_MotionInfo->m_fS = 1.0f;
    // calculate new value,
    // this is the result of either the dest has reached or the character has collided
    // fS is set to 1.0 whenever this is encountered
    else if(l_transform->m_MotionInfo->m_fS == 1.0f)
            // move character
            l_transform->m_MotionInfo->m_vEndPos    = l_transform->nextWayPoint();
            l_transform->m_MotionInfo->m_vStartPos    = l_transform->getPosition();
            D3DXVECTOR3 vDist            = l_transform->m_MotionInfo->m_vEndPos - l_transform->m_MotionInfo->m_vStartPos;
            l_transform->m_MotionInfo->m_fDist            = D3DXVec3Length(&vDist);                                
            // reset
            if (l_transform->m_MotionInfo->m_fDist > 0.1)
                l_transform->m_MotionInfo->m_fS            = 0.0f;

Share this post

Link to post
Share on other sites

Why do you divide by distance?

I assume m_fS is the interpolation value to go from startpos to endpos, so you should just do:

l_transform->m_MotionInfo->m_fS += (l_transform->m_MotionInfo->m_fSpeed * m_fElapsedTime);


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