hey guys,
i have a model that has animation on it, i know how to loop the animation using the setFrameLoop function, but i was wondering how you get those frames to only play through once instead of looping?
thanks for any help
model animation
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
Code: Select all
//! Sets looping mode which is on by default.
/** If set to false, animations will not be played looped. */
virtual void setLoopMode(bool playAnimationLooped) = 0;
For some reason the setLoopMode function isnt working for me.
Code: Select all
void Enemy::Update(float frameDeltaTime)
{
core::vector3df pos = node->getPosition();
core::vector3df player = turtle->node->getPosition();
float DistancefromPlayer = pos.getDistanceFrom(player);
if(pos.getDistanceFrom(player) > 110){//guard
if(node->getFrameNr()> 10)
node->setFrameLoop(1,11);
enemyPosition.X += 30.0f * frameDeltaTime * cos((3.14 *(Eangle-90))/180);
enemyPosition.Z -= 30.0f * frameDeltaTime * sin((3.14 *(Eangle-90))/180);
Eangle += 0.2;
}
if(pos.getDistanceFrom(player) < 100 && pos.getDistanceFrom(player) > 51){//hide
if(node->getFrameNr()> 76||node->getFrameNr() <65){
node->setFrameLoop(66,77);
node->setLoopMode(false);
}
enemyPosition.X = enemyPosition.X;
enemyPosition.Z = enemyPosition.Z;
}
if(pos.getDistanceFrom(player) < 50){//die
if(node->getFrameNr()> 64||node->getFrameNr() <50)
node->setFrameLoop(51,65);
enemyPosition.X = enemyPosition.X;
enemyPosition.Z = enemyPosition.Z;
}
cout<<pos.getDistanceFrom(player)<<endl;
enemyPosition.Y = land->terrain->getHeight(enemyPosition.X,enemyPosition.Z);
node->setPosition(enemyPosition);
node->setRotation(core::vector3df(0,Eangle,0));
}
-
- Posts: 363
- Joined: Thu Dec 16, 2010 8:50 pm
- Location: Somewhere in the clouds.. drinking pink lemonade and sunshine..
maybe try callingGundamO wrote:For some reason the setLoopMode function isnt working for me.Code: Select all
void Enemy::Update(float frameDeltaTime) { core::vector3df pos = node->getPosition(); core::vector3df player = turtle->node->getPosition(); float DistancefromPlayer = pos.getDistanceFrom(player); if(pos.getDistanceFrom(player) > 110){//guard if(node->getFrameNr()> 10) node->setFrameLoop(1,11); enemyPosition.X += 30.0f * frameDeltaTime * cos((3.14 *(Eangle-90))/180); enemyPosition.Z -= 30.0f * frameDeltaTime * sin((3.14 *(Eangle-90))/180); Eangle += 0.2; } if(pos.getDistanceFrom(player) < 100 && pos.getDistanceFrom(player) > 51){//hide if(node->getFrameNr()> 76||node->getFrameNr() <65){ node->setFrameLoop(66,77); node->setLoopMode(false); } enemyPosition.X = enemyPosition.X; enemyPosition.Z = enemyPosition.Z; } if(pos.getDistanceFrom(player) < 50){//die if(node->getFrameNr()> 64||node->getFrameNr() <50) node->setFrameLoop(51,65); enemyPosition.X = enemyPosition.X; enemyPosition.Z = enemyPosition.Z; } cout<<pos.getDistanceFrom(player)<<endl; enemyPosition.Y = land->terrain->getHeight(enemyPosition.X,enemyPosition.Z); node->setPosition(enemyPosition); node->setRotation(core::vector3df(0,Eangle,0)); }
Code: Select all
setLoopMode();
how often do you call
Code: Select all
Enemy::update()
EDIT: try this code....
Code: Select all
void Enemy::Update(float frameDeltaTime)
{
core::vector3df pos = node->getPosition();
core::vector3df player = turtle->node->getPosition();
float DistancefromPlayer = pos.getDistanceFrom(player);
if(pos.getDistanceFrom(player) > 110){//guard
if(node->getFrameNr()> 10)
node->setFrameLoop(1,11);
enemyPosition.X += 30.0f * frameDeltaTime * cos((3.14 *(Eangle-90))/180);
enemyPosition.Z -= 30.0f * frameDeltaTime * sin((3.14 *(Eangle-90))/180);
Eangle += 0.2;
}
if(pos.getDistanceFrom(player) < 100 && pos.getDistanceFrom(player) > 51){//hide
if(node->getFrameNr()> 76||node->getFrameNr() <65){
node->setLoopMode(false);
node->setFrameLoop(66,77);
}
enemyPosition.X = enemyPosition.X;
enemyPosition.Z = enemyPosition.Z;
}
if(pos.getDistanceFrom(player) < 50){//die
if(node->getFrameNr()> 64||node->getFrameNr() <50)
node->setLoopMode(false);
node->setFrameLoop(51,65);
enemyPosition.X = enemyPosition.X;
enemyPosition.Z = enemyPosition.Z;
}
cout<<pos.getDistanceFrom(player)<<endl;
enemyPosition.Y = land->terrain->getHeight(enemyPosition.X,enemyPosition.Z);
node->setPosition(enemyPosition);
node->setRotation(core::vector3df(0,Eangle,0));
}