1
$\begingroup$

I have an animated enemy chasing the player. On the enemy's rig, I save the animation's current frame to a property. I use this property to cue sounds.

It works fine when the player is looking at the enemy. However, when the player turn's their back and the enemy goes out of view, the animation freezes. I can tell that it has frozen because the property I am saving the current frame to stops incrementing. When the player looks back at the enemy, the animation starts from the beginning.

I'm assuming that this is something Blender does intentionally for performance reasons. Can I make it stop?

$\endgroup$
1
  • 1
    $\begingroup$ Right now, I have found a hackish workaround that involves copying keyframe values from separate empties that just count. I'd rather know a way to have Blender not freeze my rig, though. $\endgroup$ – Zachary May 4 at 0:51
0
$\begingroup$

Any animation that is not seen by the active camera is culled, this is called frustum-culling. As for a solution for it, I am not 100% sure this is a solution, but you can disable frustum culling for a particular camera at run-time with the following code. KX_Camera.frustum_culling Which is layman terms looks something like this.

import bge

def main(self):

  self.owner.scene.cameras["Camera_Name"].frustum_culling = False

There is also another option called KX_Scene.activity_culling. Again, I am not sure exactly if this only applies to object logic, and not also object animation. The code for it can be found below.

import bge

def main(self):

  self.owner.scene.activity_culling = False
$\endgroup$
1
  • $\begingroup$ Thank you for this! Unfortunately, it looks like the animation is culled anyway. My workaround works reasonably, though. $\endgroup$ – Zachary May 6 at 0:20
0
$\begingroup$

If it helps, there are numerous functions to get/set/activate actions at run-time.

KX_GameObject.playAction()

KX_GameObject.stopAction()

KX_GameObject.getActionFrame()

KX_GameObject.getActionName()

KX_GameObject.setActionFrame()

KX_GameObject.isPlayingAction()
$\endgroup$
2
  • $\begingroup$ I did try those, but the animation still freezes outside of the camera's frustum, even if I attempt to set the animation's action frame directly with setActionFrame(). $\endgroup$ – Zachary May 7 at 20:05
  • $\begingroup$ Unfortunate. I don't think I have any more ideas for a solution. Sorry. :( $\endgroup$ – RandomPanda May 9 at 1:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.