Hi,
i have implemented click n run concept like in a rpg game using the createFlyStraightAnimator function.
is there another method of animation other than createFlyStraightAnimator???
i have no control over this animation. so i have no idea when it gets played or at what particular condition does it end. i heard that people normally create their own animation functions. is this true n will i have to do the same.
if so can anyone plz help me out...
Thnx
how to control animation
-
- Posts: 370
- Joined: Mon Aug 29, 2005 10:54 pm
- Location: http://web.utk.edu/~pfox1
You can't control a fly straight animator, once it's off it's off until it's destroyed. Instead, try saving the point that you want your person to move to, and have them move each frame towards that point, this way if you click another position, your character will change course towards that position.
You can check your condition here in animateNode(ISceneNode* node, u32 timeMs) function:
If you want to control parameters as runtime, you can add set and get methods. Since I know Spintz was started implementation of these methods, but don't know whether these things are yet uploaded. So, can post how you can make it for yourself:
In ISceneNodeAnimatorFlyStraight.h
In CSceneNodeAnimatorFlyStraight.h
In CSceneNodeAnimatorFlyStraight.cpp
Hope this will help.
Code: Select all
if (!Loop && t >= TimeForWay)
pos = End;
In ISceneNodeAnimatorFlyStraight.h
Code: Select all
virtual core::vector3df getStartPoint() =0;
virtual core::vector3df getEndPoint() =0;
virtual core::vector3df getVector() =0;
virtual f32 getWayLength() =0;
virtual f32 getTimeFactor() =0;
virtual u32 getStartTime() =0;
virtual u32 getEndTime() =0;
virtual u32 getTimeForWay() =0;
virtual bool getLoop() =0;
virtual void setStartPoint(core::vector3df start) =0;
virtual void setEndPoint(core::vector3df end) =0;
virtual void setVector(core::vector3df vector) =0;
virtual void setWayLength(f32 wayLength) =0;
virtual void setTimeFactor(f32 timeFactor) =0;
virtual void setStartTime(u32 startTime) =0;
virtual void setEndTime(u32 endTime) =0;
virtual void setTimeForWay(u32 timeForWay) =0;
virtual void setLoop(bool loop) =0;
Code: Select all
virtual core::vector3df getStartPoint();
virtual core::vector3df getEndPoint();
virtual core::vector3df getVector();
virtual f32 getWayLength();
virtual f32 getTimeFactor();
virtual u32 getStartTime();
virtual u32 getEndTime();
virtual u32 getTimeForWay();
virtual bool getLoop();
virtual void setStartPoint(core::vector3df start);
virtual void setEndPoint(core::vector3df end);
virtual void setVector(core::vector3df vector);
virtual void setWayLength(f32 wayLength);
virtual void setTimeFactor(f32 timeFactor);
virtual void setStartTime(u32 startTime);
virtual void setEndTime(u32 endTime);
virtual void setTimeForWay(u32 timeForWay);
virtual void setLoop(bool loop);
Code: Select all
core::vector3df CSceneNodeAnimatorFlyStraight::getStartPoint()
{
return Start;
}
core::vector3df CSceneNodeAnimatorFlyStraight::getEndPoint()
{
return End;
}
core::vector3df CSceneNodeAnimatorFlyStraight::getVector()
{
return Vector;
}
f32 CSceneNodeAnimatorFlyStraight::getWayLength()
{
return WayLength;
}
f32 CSceneNodeAnimatorFlyStraight::getTimeFactor()
{
return TimeFactor;
}
u32 CSceneNodeAnimatorFlyStraight::getStartTime()
{
return StartTime;
}
u32 CSceneNodeAnimatorFlyStraight::getEndTime()
{
return EndTime;
}
u32 CSceneNodeAnimatorFlyStraight::getTimeForWay()
{
return TimeForWay;
}
bool CSceneNodeAnimatorFlyStraight::getLoop()
{
return Loop;
}
void CSceneNodeAnimatorFlyStraight::setStartPoint(core::vector3df start)
{
Start = start;
Vector = End - Start;
WayLength = (f32)Vector.getLength();
Vector.normalize();
TimeFactor = WayLength / TimeForWay;
}
void CSceneNodeAnimatorFlyStraight::setEndPoint(core::vector3df end)
{
End = end;
Vector = End - Start;
WayLength = (f32)Vector.getLength();
Vector.normalize();
TimeFactor = WayLength / TimeForWay;
}
void CSceneNodeAnimatorFlyStraight::setVector(core::vector3df vector)
{
Vector = vector;
}
void CSceneNodeAnimatorFlyStraight::setWayLength(f32 wayLength)
{
WayLength = wayLength;
}
void CSceneNodeAnimatorFlyStraight::setTimeFactor(f32 timeFactor)
{
TimeFactor = timeFactor;
}
void CSceneNodeAnimatorFlyStraight::setStartTime(u32 startTime)
{
StartTime = startTime;
}
void CSceneNodeAnimatorFlyStraight::setEndTime(u32 endTime)
{
EndTime = endTime;
}
void CSceneNodeAnimatorFlyStraight::setTimeForWay(u32 timeForWay)
{
TimeForWay = timeForWay;
}
void CSceneNodeAnimatorFlyStraight::setLoop(bool loop)
{
Loop = loop;
}