Game Development Community

Playing ShapeBaseImageData Animation

by James Tracey · in Torque Game Engine · 01/11/2006 (4:28 pm) · 8 replies

I have a chain gun that has a fire animation that spins the barrel 360 degrees.
I set stateTimeoutValue[3] to 0.01 to fire at a high rate.
The problem is that the fire animation never gets to play all the way.
How can I mannualy play the fire animation so I can still fire at a high rate?
Thanks in advance.

#1
01/12/2006 (4:56 am)
The way I got around this problem was to use a partial animation.

If the chain gun has 10 barrels, only roatate the gun by 36 degrees in your animation for the duration of your fire sequence.

At the end of the firing sequence, your next barrel will be in place where the first one was and you can fire your weapon again.

Essentially, your gun moves back to its original position, but no-one notices because all of the barrels are the same.

You shouldn't have to do anything other than make the animation, not worrying about getting them in time because by default, animations are scaled to the stateTimeout value.

Hope this helps.

I did some research into the weapon state system and it really is very powerful once you understand it.
It's very easy to create spin-up and spin-down states for your weapon too.
#2
01/12/2006 (5:33 am)
I've made a simple state diagram for how I think a chaingun should work.
I'm not currently near a torque installation so I can't check it for accuracy but it's basically like this.

www.cerebral-bicycle.co.uk/images/chaingun.jpg
As you can see, there are 4 spin-up states and 4 spin-down states. Each of these plays a partial animation with the chain gun at different speeds. You could also include sounds going from one speed to another...

If done well, you'd end up with a chain gun which builds up speed as you hold down the mouse and then fires. If you let go of the fire button, it would spin down from it's current speed.. That's the theory anyway.

Just to note, there's no code required for this, no torquescript anyway, just the state definitions in the weapon file. The state machine will do the rest.

If anyone notices any mistakes, please let me know and I'll correct the image.
#3
01/12/2006 (9:13 am)
Hey Jason,

The transition diagram looks great...really clears up the concept.

Stupid question, but what program did you use to create it?

Having a state diagram for a weapon like that probably just saved about 20 emails of mis-communication about what people meant.

Todd
#4
01/12/2006 (9:23 am)
I used Visio 2003. But I'm sure it's possible to make state diagrams like this using other tools.

I always think a picture is best for stuff like this. Words get in the way.
If I think on, I'll do one for the standard crossbow so people can compare code vs diagram.
#5
01/12/2006 (9:44 am)
Cool, thanks.
#6
01/13/2006 (3:01 am)
OK. Here's the standard crossbow.

As you can see, it's a very simple weapon, most of the decision work being done in the NoAmmo state.

www.cerebral-bicycle.co.uk/images/crossbowstate.jpg
Hope this helps.
#7
01/14/2006 (11:43 am)
I couldn't get it to look as good as I wanted, until I set stateTimeoutValue to 0, now it works great.
Thanks for your help.
#8
06/08/2006 (1:23 pm)
There's also a spin thread state built into the state machine that handles chainguns. I'm not exactly sure how to set it up but I came across it last night.