Getting frame number help

hello…

i wish to get the frame number I am on for an action in my rig.

I have ActionActuator on, and a float property “Number” attached to the “frame property” option in the actuator.

i also have a property sensor that is set so that whenever “Number” == a value, it does some other stuff…

but this is no working. i have Debug enabled in game for Number, and it is working. The value of the property is increasing until the animation ends. but, the property sensor never triggers, and using print statements in a python file, it seems the property is always 0, yet the debug shows otherwise in run-time?

Can somebody please help me?

Also, how would I use the python ActionActuator.frame method to do a similar result myself?

Thanks so mcuh, it is much help!

Edit, my logic:

PlayerRig: WeaponObj: PlayerRig:
PropertySensor —>PythonCont—>ActionAcuator
(set as equals)

Python code:

sens = cont.sensors[‘PropSens’]
PropSens.value = 74 (with my game logic property set to int)
if PropSens.positive:
print(“Victory!”)

Then I also have a debug loop…
for i in range(0, 150):
print(PlayerRig[‘PropSense’]

I have tried multiple debugs… as said before, they always return that the value is 0. Same for if I try using.frame method. Please somebody tell me what I must be do wrong.

You have (float) property, and animation counts as float. You probably see frames like 23.9800 and next frame is example 24.012.
Now we test if 24 equals 24.012 -> Nope.
Set your property to integrer and it should work. But is very dangerous trigger important happenings with this beqouse, if game lag just that moment and that frame skipped. Less important actions may triggered with that way of course (Like walk sound in certain frame)
In python we can use it same way.

if (int(frame)==24):
do something…

Instead of using equals, use range, so 24 to 30. Then it will trigger on the 24.00012

i have updated my original post with my logic and python. I tried both of your solutions and niether have worked :frowning:

use logic to handle the animation?

trigger--------------and-------------property =1
propert anim=0------/

if property min 1 max (end frame -1)------and-------add 1 to anim

if changed-------------and---------action property based anim

this way you can use anim to trigger other logic

if anim =71----and-------message to a bottle

I have also tried now just setting my proprty sensor to just changed, to see if it is changing at all… it is not.

Am I not understanding the frame properties option in action actuator right? Doesn’t it send the value into whatever property you have declared?

also bpr I am not to sure of what your code is saying, or how it is better than mine… can you elaborate on it?

I have done essentially the same as BPR in the past, but formatted a little differently.

The problem is, I think, is when you have the action and property sensors not controlled on the object. At least when I tried something similar to what you were doing, that is what I deduced to be an issue.

Here is a .blend that does what it sounds like you want: framecount.blend (509 KB)

It’s probably not the most elegant way of handling this, but it works.

-KB

In python we can read animation frames directly without any properties.
Next example is ripped from our game and do nothing at lone.
I wish if it helps to show, how that work. This time python code is module not a scipt.

Logic:
Always (with true pulse) — Python (module name.main) ---- (none)


import bge
cont=bge.logic.getCurrentController()
scene = bge.logic.getCurrentScene()
objects = scene.objects
own=cont.owner
avarmature='armature' #object name
armature=objects[avarmature]
own['noiseframe']=0

def main():
    frame=int(armature.getActionFrame(0)) #Listen animation layer 0
    if frame==1:
        own['noiseframe']=1
    if frame==13 or frame==29:
        if frame!=own['noiseframe']:
            own['noiseframe']=frame
            print ('Klop klop')

As mentioned earlier, frames are floats. Checking with equal does not really work as you would not match the exact precission of a float number.

What you can do is to make the measuring property an integer. Then you can check with equal on this one with a whole number. Be aware this check might have several solutions e.g 2.1666 == int 2 and 2.73333 == int 2

Nevertheless is the design of you logic really a good one?

I think you want to play an animation. When the animation ends you want to do a decision what comes next.
So all you need is to determine when the animation ends. You do not need to look for the frame number. The action actuator already knows the end. You can check that with the ActuatorSensor.

How to: create Action sequences with logic bricks - the power of the ActuatorSensor

I have an actuator I wanted to go off when at a specific frame is passed in the middle of my animation… to remove a parent on an object.

damutantmans file served my purpose :).

thanks everybody else though, the information is great!