Game Development Community

Animated Projectiles with Bones

by Jeff Woods · in Torque Game Engine Advanced · 07/07/2009 (3:19 pm) · 11 replies

Hi, all.

I'm creating a game which requires the player character to "kick" kittens into targets around several levels. Being an artist with little to no coding skills, I've decided to make a very hacky attempt to go about this by having the player hold the kitten in his main .dts. This allows me to animate the kitten's squirming very accurately along with the player's various movements.

When the player "fires" his invisible kitten weapon, I have a kitten projectile emit from the muzzle point. This is all well and good, but I need the kitten projectile to have appropriate animations instead of simply flying through the air as a static mesh.

I've tried embedding an animation of the kitten scrambling through the air into the kitten's projectile mesh. This animation plays perfectly in Showtool. But, in the TGEA it simply doesn't play.

Does anyone know an easy fix to this, so I can move on to getting these kittens booted about?

There's a screen grab from my Kitten Kicker game below.

[IMG]http://i72.photobucket.com/albums/i200/PontiusChristo/th_billy-and-kitten.j...

About the author

Recent Threads


#1
07/07/2009 (3:44 pm)
I haven't actually done anything like this but if you're using a standard projectile OnFire function try this:
%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
      client           = %obj.client;
%p.playthread(0, theanimation);
};

"playthread(#, anim_name)" is the function to play an animation. Make sure that your animation is saved/exported inside the model/dts.
#2
07/07/2009 (3:44 pm)
There's no fix, because it's not a bug. You don't usually animate projectiles with bones as it's expensive. Animation threads are created but you'd have to name them "ambient" if my memory is right.
#3
07/07/2009 (3:47 pm)
At Steve:

Thanks. I'll try that.

At Stefan:

I totally understand the expense it would generate. But, this is just a single player game where most of the overhead comes from the player character and those animated kittens.

Again. I'll try it.
#4
07/07/2009 (4:04 pm)
Thanks for your replies.

I'm still not sure if I can make this work. I'll keep at it for a while then move on to other matters.
#5
07/07/2009 (5:28 pm)
I'm pretty sure Projectiles have no capacity for any sort of animation at all by default. So you'd have to ad that to the engine first.

...Oh wait, that was a lie :P. I don't know why I got that idea in my head. Looking in projectile.h reveals there are two animation threads associated with Projectiles: mActivateThread and mMaintainThread. In Projectile::onAdd, these threads are initialised to use sequences defined in the datablock. In ProjectileData::preload, you can see where these vlues are initialised - the datablock searches for animations named 'activate' and 'maintain'. I'd try those, for a start.
#6
07/07/2009 (8:27 pm)
Activate, I think[if I remember correctly], is when the projectile appears, and the Maintain, is used 'during flight'.

So, you could have the kitten projectile have the Maintain sequence as it 'flies' thru the air and the Activate when the kitten projectile emerges/appears, could be both same sequence....
#7
07/07/2009 (9:55 pm)
Oh, and I'll be the first to say your game looks absolutely sadistic, but sounds like it could be fun ;)
#8
07/07/2009 (10:11 pm)
I believe getting the kittens to scramble around as they fly through the air is super important to the overall disturbed nature.

I've been working on this off and on for a while and I'm in over my head with this.

So far, it looks pretty comical to have the kittens simply strike a terrified, albeit, stationary pose as they fly out of the player's foot.

I'm still working on this and if I get anything notable to reply to, I'll let you guys know.

And thanks for your replies. They've opened up alot of good ideas to me.
#9
07/08/2009 (12:05 pm)
Awesome idea!

You may be able to check out some Tribes2 models (I'm sure it can still be downloaded somewhere -- it was made free a few years ago). It used animated projectile and explosion DTS shapes -- as well as particles. I'm almost certain that Torque still retains that capability (thinking of Legends and Starsiege 2845).

I'm thinking it's something as simple as having a certain named cyclic sequence in your cat model... yet I could be wrong.

But do show us this flying attack kitty when you get it figured out -- I'd love to see a video of that :D
#10
07/08/2009 (12:20 pm)
lol, you could use the Fred Penner Song "The Cat Came back" as the theme song :)
#11
07/08/2009 (1:23 pm)
I will definitely send you some flailing kitten videos when I crack this nut.

And I'm not sure if the kittens will come back since we want them to explode on impact of the target... Aqua Teen-style.