This is a great looking tutorial - I will be looking forward to using this! - epsas

I get a 404 - File not found when trying to download the source for this demo :-(

Reworked Move the Robot section to fix bugs.

I fixed a several bugs in the code. For example the nextLocation() method made no sense because it would pop off the second location before the first location had been arrived at. The reason was that a previous step had you set the animations and then a subsequent step had you add more code that called nextLocation(). This guaranteed to clear the stack in at least 2 frames. I reworked the entire Moving the Robot section to fix this problem.

Kraythe 20:17, 4 November 2005 (CST)

Ambiguous Code

The FrameStarted function in the MoveDemoListener class is not written out very well, leading to ambiguous code and faulty results. Here is the completed frameStarted function.

    bool MoveDemoListener::frameStarted(const FrameEvent &evt)
    {
        if (mDirection == Vector3::ZERO) 
        {
            if (nextLocation()) 
            {
                // Set walking animation
                mAnimationState = mEntity->getAnimationState("Walk");
                mAnimationState->setLoop(true);
                mAnimationState->setEnabled(true);
            }
        }
        else
        {
            Real move = mWalkSpeed * evt.timeSinceLastFrame;
            mDistance -= move;
            if (mDistance <= 0.0f)
            {
                mNode->setPosition(mDestination);
                mDirection = Vector3::ZERO;
                // Set animation based on if the robot has another point to walk to. 
                if (! nextLocation())
                {
                    // Set Idle animation                     
                    mAnimationState = mEntity->getAnimationState("Idle");
                    mAnimationState->setLoop(true);
                    mAnimationState->setEnabled(true);
                } 
                else
                {
                    // Rotation Code will go here later
                }
            }            
            else
            {
                mNode->translate(mDirection * move);
            } // else
        } // if

        mAnimationState->addTime(evt.timeSinceLastFrame);
        return ExampleFrameListener::frameStarted(evt);
    }


ImaTard 18:20, 3 September 2007 (PST)