Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17560

Why does the agent keep spinning around?

$
0
0
// This code is for processing motions
float startDir = l_transform->getDirection().x;
float endDir = l_transform->m_MotionInfo.fDir;
D3DXVECTOR3 vStartDir(startDir, 0, 0);
D3DXVECTOR3 vEndDir(endDir, 0, 0);
D3DXVECTOR3 vFinalDir;
D3DXVec3Lerp(&vFinalDir, &vStartDir, &vEndDir, l_transform->m_MotionInfo.fS);
l_transform->setRotation(D3DXVECTOR3(vFinalDir.x, 0, 0));
 
// This code is called when process motions is called
void Transform::setRotation(D3DXVECTOR3 r)
{
    this->m_vRot = r;
}
 
// This code is called after the Update method of Transform, the direction is extracted from the local/world matrices
D3DXVECTOR3 Transform::getDirection()
{
    return this->m_direction;
}
 
void Transform::Update(float dt)
{    

    D3DXMatrixIdentity(&m_localMatrix);
    D3DXMatrixIdentity(&m_worldMatrix);

    if (m_vRot.x != 0.0f || m_vRot.y != 0.0f || m_vRot.z != 0.0f)
    {
        D3DXQuaternionRotationYawPitchRoll(&m_rotation, m_vRot.x, m_vRot.y, m_vRot.z);
        D3DXMatrixTransformation(&m_localMatrix, &m_scaleCenter, NULL, &m_scale,
            &m_rotationCenter, &m_rotation, &m_position);
    }
    else
    {
        D3DXMatrixTransformation(&m_localMatrix, &m_scaleCenter, NULL, &m_scale,
            &m_rotationCenter, NULL, &m_position);
    }    

    // check if current object is attach to other object
    // check if m_matWorld = *m_pCombineFrameMatrix works
    //if (combinedMatrix != NULL)
    //    matWorld *= *combinedMatrix;

    if (m_simObject->m_pAnimController != NULL) {
        m_simObject->m_pAnimController->AdvanceTime(dt, NULL);
    }

    this->m_right = D3DXVECTOR3(this->m_localMatrix._11, this->m_localMatrix._21, this->m_localMatrix._31);
    this->m_up = D3DXVECTOR3(this->m_localMatrix._12, this->m_localMatrix._22, this->m_localMatrix._32);
    this->m_direction = D3DXVECTOR3(this->m_localMatrix._13, this->m_localMatrix._23, this->m_localMatrix._33);   

    this->m_worldMatrix = this->m_localMatrix;

    if (this->m_simObject->m_parent != NULL)
    {
        this->m_worldMatrix = this->m_simObject->m_parent->m_transform->m_worldMatrix * this->m_worldMatrix;
    }
}
 

The agent has no animation controllers

Could anyone help me please?

Thanks

Jack

Curr Dir: 0 New Dir: 6.28319

Curr Dir: -0.361539 New Dir: 6.28319

Curr Dir: -0.408553 New Dir: 6.28319

Curr Dir: -0.698545 New Dir: 6.28319

Curr Dir: -0.810868 New Dir: 6.28319

Curr Dir: -0.971059 New Dir: 6.28319

Curr Dir: -0.997259 New Dir: 6.28319

Curr Dir: -0.884236 New Dir: 6.28319

Curr Dir: -0.518006 New Dir: 6.28319

Curr Dir: 0.0442299 New Dir: 6.28319

Curr Dir: 0.654501 New Dir: 6.28319

Curr Dir: 0.958705 New Dir: 6.28319

Curr Dir: 0.992126 New Dir: 6.28319

Curr Dir: 0.884634 New Dir: 6.28319

Curr Dir: 0.710303 New Dir: 6.28319

Curr Dir: 0.431654 New Dir: 6.28319

Curr Dir: 0.123819 New Dir: 6.28319

Curr Dir: 3.01992e-007 New Dir: 4.5219

Curr Dir: -0.118422 New Dir: 4.5219

Curr Dir: -0.142114 New Dir: 4.5219

Curr Dir: -0.274094 New Dir: 4.5219

Curr Dir: -0.296881 New Dir: 4.5219

Curr Dir: -0.429561 New Dir: 4.5219

Curr Dir: -0.462019 New Dir: 4.5219

Curr Dir: -0.582648 New Dir: 4.5219

Curr Dir: -0.629358 New Dir: 4.5219

Curr Dir: -0.730759 New Dir: 4.5219

Curr Dir: -0.785888 New Dir: 4.5219

Curr Dir: -0.865074 New Dir: 4.5219

Curr Dir: -0.914811 New Dir: 4.5219

Curr Dir: -0.960015 New Dir: 4.5219

Curr Dir: -0.989335 New Dir: 4.5219

Curr Dir: -0.999997 New Dir: 4.5219

Curr Dir: -0.986819 New Dir: 4.5219

Curr Dir: -0.944587 New Dir: 4.5219

Curr Dir: -0.858214 New Dir: 4.5219

Curr Dir: -0.739458 New Dir: 4.5219

Curr Dir: -0.585572 New Dir: 4.5219

Curr Dir: -0.384383 New Dir: 4.5219

Curr Dir: -0.176508 New Dir: 4.5219

Curr Dir: 0.0471163 New Dir: 4.5219

Viewing all articles
Browse latest Browse all 17560

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>