Keying game object properties?

Is this possible? If not, is there a rough approximation of keying (keyframing) game engine properties?

For example, say your character needs to throw an rock. At the beginning of the animation sequence the character is just winding his arm back, and nothing really needs to happen logic wise, but somewhere in the middle of the animation he releases the rock, and from there game logic would take over.

Intuitively, what I want to do is animate the throw action, and somewhere in the middle change a property on the character object to trigger a property change sensor and initiate the spawning of the rock.

I am really at a loss for how to manage this sort of synchronization between animation and game logic.

use a property to forward your animation

this is logic based solution *

So property sensor ->< If property “Animation” is equal to or greater then 1 while less then(1 frame before End Frame
if keypress (trigger key) ---------------------------------------------------------------------and-----------------------Property assign 1 property
if animation = 0---------------------------------------------------------------------------------/
if Animation >1 while animation <1 frame before End frame--------------------------------and-------------------------Property Add 1 to “animation”
if animation = end frame------------------------------------------and-----------------------------------------Animation =0

the if animation = 0 I call “State check” which means you can’t re-start the animation in the middle,

so with this “Animation” can trigger anything, including python

So your “Action” needs to advance by using the property animation :slight_smile:

I am also sure you could use python to set up a property


own[‘Animation’]= GetActionFrameNumber

or something like that

Ok, I see what needs to happen. I have to set up a frame property in the Action actuator. That will get me the inversion of control I want. Then it is just a matter of adding a property sensor for the frame property at the ‘release’ frame for the rock.

I see what you are saying about state checking, but this was just a very basic conceptual issue as far as synchronizing logic with animation. My issue is that I never even bother to look at the actuators when trying to figure out how to trigger a sensor at a given frame.

Thanks for the help.

No problem :slight_smile:

I use this almost exclusively and rarely use actions at all, as they can not be changed in action,

I am a big fan of rag dolls and skeletal animation systems
Like if frame = 5 apply force X

So I make “force maps” rather then “animations”

check this out…


RunFast.blend (1.95 MB)WRectification.blend (779 KB)

In the case of throwing an object there is another approach that is common.

You keep the player and the object as separate objects. You have a dedicated bone in the hand of your player and when you want him to hold the object, you parent the object to that bone in the model’s hand. Then all your animations can run and the player can be holding an item or not.

To throw the item, one way to do it would be to design your animation so you know how long it takes from the start of the animation to the release. When you start the ‘throw’ animation you also start a timer and when the timer expires you unparent the object, apply the throwing force, and away it goes. Of course, you can also use the frame counter to tell when to release the ball as well.

Excellent adivice Re: Parenting held objects. I would explicitly like to avoid using timers for calculating when to throw though, because that does not seem like it would be portable across framerates. Probably not an issue in practice, but I prefer a more abstract solution where possible.

@BPR: Yeah, I think much later on I will also probably prefer a more dynamic sort of physics-aware character control method, but as you can tell I have a LOOOONG way to go before I tackle that.

For now I think I will stick to logic bricks as much as possible, and if they get in the way as I go along, I guess I will have to change strategies.

Python is very powerful,

everything I do i logic you can do in python, without limits,
but as you can see it is harder to know “all there is to know” because your head might pop!

Try to solve problems that need to go in order with python

solve little here and there problems with logic, unless you need to pass it around