Animation and char position

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
itzjac
Posts: 57
Joined: Fri Nov 17, 2006 7:41 pm
Location: Mexico City

Animation and char position

Post by itzjac »

Hello, i got running the blending animations for my char, thank to the engine it looks awesome!
By now only moves forward but am planning to implement all directions.

Am using the OnAnimationEnd callback to return to the Idle position, but since my char is moving forward I want it to really change its position.
Now its only jumping back to the initial position.

Code: Select all

 
void EventReceiver::OnAnimationEnd(irr::scene::IAnimatedMeshSceneNode* pAnimNode)
{
    pAnimNode->setTransitionTime(0.2f);
    pAnimNode->setFrameLoop(0, 24);
    pAnimNode->setLoopMode(true);
    pAnimNode->setAnimationSpeed(30);
    pAnimNode->setAnimationEndCallback(0);
}
 
I wonder what would be the best approach to solve this.
  • I tried getting the root joint (one at the top hierarchy of the bones in the skeleton) while the callback is executed, then I get its absolute position and add it to the current position of the animNode (only for one of the axis), this doesn't work, am still getting a twitch, because the locations doesn't match perfectly

    Another option; keep adding the direction with the key event pressed ASWD. Couldn't make it look good, tweaking the offset value to match the animation timing seems too hacky, but perhaps am missing a very basic foundation?
Am not sure if the engine provides a mechanism to sync animation with position, does it?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Animation and char position

Post by mongoose7 »

I think your character animation should take place "on the spot" and you should move the scene node to create forward motion.
itzjac
Posts: 57
Joined: Fri Nov 17, 2006 7:41 pm
Location: Mexico City

Re: Animation and char position

Post by itzjac »

So, this is an asset problem.
What I infer from your statement is to start Forward animation at point B, where it will end?
It's a pitty because I need the animator to help me changing its animation set to create every action "on the spot", hmmm.... am gonna ask him that, thank you!
itzjac
Posts: 57
Joined: Fri Nov 17, 2006 7:41 pm
Location: Mexico City

Re: Animation and char position

Post by itzjac »

Good! I corrected the animations, I've got a smoother movement but, what does the engine used to interpolate a change of node position?
Setting a very low speed value helps to avoid jumps between old and new position

Code: Select all

 
core::vector3df vVel(core::vector3df(0.0f, 0.0f, -0.0001f));
pAnimNode->setPosition(pAnimNode->getPosition() + vVel*fDeltaTime));
 
If I increase the speed value, for a faster movement, a camera close up reveals an obvious jump of position.

In the examples movement and demo uses createFlyStraightAnimator for the char to be moved and looks great, but I don't think this is what I want, besides creating and dropping the animator every time there's a key action doesn't sound correct.
Appreciate the help if anyone can can share more info about this.
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Animation and char position

Post by mongoose7 »

Implement your own animator to take account of the variety of actions that you will want to do.

Those animators are just toys for script kiddies to download Irrlicht, make something that moves and then move on. If you want more you will have to roll up your sleeves and get on with it.
itzjac
Posts: 57
Joined: Fri Nov 17, 2006 7:41 pm
Location: Mexico City

Re: Animation and char position

Post by itzjac »

If you want more you will have to roll up your sleeves and get on with it.
Ok I got it working at least one direction ;)

BTW, does anyone know why do I get an strange artifact when specifying the update mode for the joints?

Code: Select all

 
pAnimatedNode->setJointMode(scene::EJUOR_CONTROL);
 
Even by only activating blending I get the same artifact and without moving the object

Code: Select all

 
pAnimatedNode->setTransitionTime(0.2f);
 
On the right it shows the artifact, on the left how it is normally rendered without using any of the above options.

Image
itzjac
Posts: 57
Joined: Fri Nov 17, 2006 7:41 pm
Location: Mexico City

Re: Animation and char position

Post by itzjac »

Maybe this problem should be posted on a new thread???
Post Reply