Problem with the Images state system
by Kimberly Unger · in Torque Game Engine · 10/15/2003 (5:42 pm) · 3 replies
I have an object that I've mounted a Image (a gun) with mountImage. The gun has the following animation sequences root, Hidden, Emerge, Idle, ThreeShoot, BigShoot, PutAway. To get to the state 'PutAway' I created a setImageState function in the engine that calls the baseshape function of the same name. The function works just fine and all of the Image states are executed as expected but the PutAway and Hidden sequences don't play.
The state system is setup as follows
// Initial start up state
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
// Activating the gun. Called when the weapon is first
// mounted and there is ammo.
stateName[1] = "Activate";
stateAllowImageChange[1] = true;
stateTransitionOnTriggerDown[1] = "Emerge";
stateSequence[1] = "Hidden";
// Ready to fire, just waiting for the trigger
stateName[2] = "Ready";
stateAllowImageChange[2] = true;
stateTransitionOnTriggerDown[2] = "Fire";
stateSequence[2] = "Idle";
// Fire the weapon. Calls the fire script which does
// the actual work.
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Ready";
stateTimeoutValue[3] = 0.1;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
// Play the Emerge animation, and transition into
stateName[4] = "Emerge";
stateTransitionOnTimeout[4] = "Ready";
stateAllowImageChange[4] = true;
stateTimeoutValue[4] = 0.5;
stateSequence[4] = "Emerge";
// Play the PutAway animation, and transition into
stateName[5] = "PutAway";
stateTransitionOnTimeout[5] = "Activate";
stateAllowImageChange[5] = true;
stateTimeoutValue[5] = 0.5;
stateSequence[5] = "PutAway";
stateScript[5] = "onPutAway";
The state system is setup as follows
// Initial start up state
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
// Activating the gun. Called when the weapon is first
// mounted and there is ammo.
stateName[1] = "Activate";
stateAllowImageChange[1] = true;
stateTransitionOnTriggerDown[1] = "Emerge";
stateSequence[1] = "Hidden";
// Ready to fire, just waiting for the trigger
stateName[2] = "Ready";
stateAllowImageChange[2] = true;
stateTransitionOnTriggerDown[2] = "Fire";
stateSequence[2] = "Idle";
// Fire the weapon. Calls the fire script which does
// the actual work.
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Ready";
stateTimeoutValue[3] = 0.1;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
// Play the Emerge animation, and transition into
stateName[4] = "Emerge";
stateTransitionOnTimeout[4] = "Ready";
stateAllowImageChange[4] = true;
stateTimeoutValue[4] = 0.5;
stateSequence[4] = "Emerge";
// Play the PutAway animation, and transition into
stateName[5] = "PutAway";
stateTransitionOnTimeout[5] = "Activate";
stateAllowImageChange[5] = true;
stateTimeoutValue[5] = 0.5;
stateSequence[5] = "PutAway";
stateScript[5] = "onPutAway";
#2
04/27/2006 (7:33 am)
It works as intended, you just have to add it to the image as you do with all states that are not in starter.fps default. All I can say is that it works.
#3
1) You're missing some timeout values
2) You will never get to the 'PutAway' state. This is hard to put into writting but hopefully you'll be able to follow:
- First state that's called is Preactivate
- If weapon is loaded it proceeds to Activate which will should play the hidden animation (except you're missing a timeout value)
- Once the trigger is pressed you jump to the Emerge state which would quickly jump to the Ready state
- You use another stateTransitionOnTriggerDown in the ready state to jump to the Fire state
- Once player has stopped firing the Ready state is called once again and then the whole thing would loop and repeat. The way you've set it up, state [5] PutAway is never being reached.
That's why PutAway isn't working. Hidden isn't working cos you're missing a timeout.
This would be a better way of setting up state [1]
I think it would also help if you placed the states in a more sequential order.
04/27/2006 (10:01 am)
I back Stefan up on this one, it does work. You just have to know how to set the states up which can be a little tricky I must admit. I did see a few things in your state system that worried me...1) You're missing some timeout values
2) You will never get to the 'PutAway' state. This is hard to put into writting but hopefully you'll be able to follow:
- First state that's called is Preactivate
- If weapon is loaded it proceeds to Activate which will should play the hidden animation (except you're missing a timeout value)
- Once the trigger is pressed you jump to the Emerge state which would quickly jump to the Ready state
- You use another stateTransitionOnTriggerDown in the ready state to jump to the Fire state
- Once player has stopped firing the Ready state is called once again and then the whole thing would loop and repeat. The way you've set it up, state [5] PutAway is never being reached.
That's why PutAway isn't working. Hidden isn't working cos you're missing a timeout.
This would be a better way of setting up state [1]
// Activating the gun. Called when the weapon is first // mounted and there is ammo. stateName[1] = "Activate"; stateTimeoutValue[1] = 0.5; stateTransitionOnTimeout[1] = "Emerge"; stateSequence[1] = "Hidden";
I think it would also help if you placed the states in a more sequential order.
Torque 3D Owner Affectworks
Does anyone have any helpful hints on getting a "PutAway" state to function properly. Where you are switching the mounted Image and the current weapons "Deactivate" animation is called first. I noticed that the FPS: SK crossbow has a deactivate animation on it and I don't see it implemented anywhere.