Coordinating Link Points with Animations and onFrameChange not being called
by Amr Bekhit · in Torque Game Builder · 02/02/2009 (1:41 pm) · 1 replies
Hello again,
In my game, I have a spear which I want to move along with the player's swing animation. The way I'm thinking of doing this is to use the onFrameChange callback to find out which frame the player sprite is currently in and to adjust the mount location of the spear accordingly. Unfortunately, the onFrameChange doesn't seem to get called at all. I initially thought it might be a namespace problem, as my player's datablock is declared as a t2dSceneObjectDatablock rather than a t2dAnimationDatablock. However, I have found that the onAnimationStart and onAnimationEnd callbacks are being called just fine.
Here is my player datablock declaration:
And here are my callback implementations:
What could be stopping onFrameChange from being called?
Also, I was wondering whether there might be a better way of coordinating link points with animations than what I plan to do? It just seems a little "manual" to me, not very neat.
Thanks
--Amr
In my game, I have a spear which I want to move along with the player's swing animation. The way I'm thinking of doing this is to use the onFrameChange callback to find out which frame the player sprite is currently in and to adjust the mount location of the spear accordingly. Unfortunately, the onFrameChange doesn't seem to get called at all. I initially thought it might be a namespace problem, as my player's datablock is declared as a t2dSceneObjectDatablock rather than a t2dAnimationDatablock. However, I have found that the onAnimationStart and onAnimationEnd callbacks are being called just fine.
Here is my player datablock declaration:
datablock t2dSceneObjectDatablock(PlayerDatablock)
{
class="Player";
CollisionActiveReceive=true;
CollisionActiveSend=true;
CollisionPhysicsReceive=true;
CollisionPhysicsSend=true;
CollisionCallback=true;
direction="down";
hSpeed=10;
vSpeed=10;
health=100;
};And here are my callback implementations:
function Player::onFrameChange(%this,%frame)
{
echo("Changed to frame " @ %frame @ "in animation " @ %this.getAnimationName());
}
function Player::onAnimationStart(%this)
{
echo("Animation " @ %this.getAnimationName() @ " has started playing.");
}
function Player::onAnimationEnd(%this)
{
echo("Animation " @ %this.getAnimationName() @ " has finished playing.");
}What could be stopping onFrameChange from being called?
Also, I was wondering whether there might be a better way of coordinating link points with animations than what I plan to do? It just seems a little "manual" to me, not very neat.
Thanks
--Amr
Torque Owner Amr Bekhit
--Amr