Game Development Community

Animation mounted to player

by Teromous · in Torque Game Builder · 02/17/2008 (12:05 pm) · 5 replies

I'm going to keep working on this one but I figured I'd post to see if any of you could help me out.
What I'm trying to do is call an animation datablock, play it, and mount it to the $player.

Any help or tips are very welcome.

#1
02/18/2008 (7:48 am)
I wasn't sure if I explained it well enough so here's a bit more detail:

I don't want to change the player's animation. What I want to do is play an animation on top of the player, so that when a button is pressed an animation will play and mount itself to the player.

Right now I have it working so that a particle effect will appear and mount itself to the player:

%healeff = new t2dParticleEffect();
%healeff.addToScene(SceneWindow2D.getScenegraph());
%healeff.loadEffect("~/data/particles/Heal2.eff");
%healeff.mount($player);
%healeff.playEffect();

But what I want to do is modify this so that instead of mounting a particle effect, it mounts an animation.
I hope somebody reads this and can help me out...
#2
02/20/2008 (7:05 pm)
Has anyone mounted an animation before?
#3
02/23/2008 (7:08 am)
Still working on it, but can't seem to get it to work. It seems like it would be a simple thing to do but I'm not familiar enough with the scripting language to work it out. All I want to do, is to add an animation to the scene, then mount it to the player so when the player moves it will stay attached to them until the animation is finished. I'm sure that somebody has done this before. I'll keep looking in the tutorial code to see if I can find where this has been done.
#4
02/23/2008 (8:17 am)
Figured it out finally. Hopefully this will help somebody else out:

%theAnim = new t2dAnimatedSprite()
{
animationName = "DesiredAnimation";
canSaveDynamicFields = "1";
Position = "14.349 -24.589";
size = "8.000 8.000";
mountID = "6";
};
%theAnim.addToScene(SceneWindow2D.getScenegraph());
%theAnim.mount($player);
#5
03/03/2008 (4:05 am)
Repeatedly mounting and dismounting has a cost - all of those mountpoints are saved and you will find your game slows down over time if you do this often. Why not just mount the animation on the player at the start of the game, and use setEnabled(true) or false to turn it on and off when needed.