Updating armature animations off camera

I’m having a problem in my game. I think it has to do with either physics being deactivated, when the object in question is off camera, or the armature not updating, when the object is off camera. I’m pretty sure it’s the latter. How do I ensure that armatures update and pose themselves even when they’re not on camera?..

*edit…

I’m pretty sure the problem is actually a raytracing issue. sorry. I’m attempting a raytrace, on a piece of geometry that’s off camera. The raytrace is returning None. Is there a way to fix this? How do I get rayTrace targets from meshes that are off camera?

There are a few things that can mess up raytrace. One of them is raycasting from an object to itself. Another is if the ray isn’t long enough, or if the object has the wrong physics settings.
Try doing it first with the object on camera, if that works, then it must be something very obscure.

Armatures don’t animate off camera, that’s a “feature” which you can’t turn off. It is helpful at keeping performance up, but can cause problems if any of your logic relies on action frames or action progress. One work around is to use a counter stored in python or a property and map the action to the counter. The counter keeps increasing even if the armature is off screen, and then when it comes back the action wills skip to the correct frame.

To be honest, that’s the right way to do it. Having gameplay mechanics rely on things happening in the display aspect of your game (the armature) is not a good design. Gameplay mechanics should really work independently of display. You’ll find that makes it easier later if you want to save the game or if you want to work on multiplayer.

This is one of the reasons that I have this love/hate relationship with BGE. It makes no sense whatsoever to make this a ‘feature’… especially one that you can’t turn off. It’s things like this that make the BGE unreliable, and unpopular. There’s no good reason to have this in the BGE at all. Even if you’re arguing for performance, there’s already code implemented in the BGE you can use that can tell if something’s on screen or not… so this is something that the user could do on their own. This isn’t a feature in my eyes… this is one of the very many reasons BGE isn’t more popular.

as far as animation is concerned you can update animation based on a property like “own[‘anim_frames’]” and you could read that…I use this when I need to keep the animation ‘frame’ updated.

for the raycast it would help if I knew what you were raycasting to, from…what you are trying to return(hit object or whatever)…and maybe seeing your code if you are using python.

on a side note…you CAN raycast to self and to test if the raycast hit something…simply check if the raycast hit nothing…hitting nothing is the same as hitting self. It tells you there is no obstruction…therefore must be casting to the target…so long as the range requirement of the raycast is met.

using a property for animation is nice anyway because you can add LinearVelocity*multiplier to the frame (when in front of camera) and the actors feet animation sync to their walk speed.


if culled:
    frame+=1
else:
    frame+= own.localLinearVelocity.x
    if frame>Max:
        frame= frame-Max
    elif frame<0:
         frame = Max+frame

as for the raycast, what are you trying to do with it?

one can build a bvhtree themselves if you really really need to raycast, or use upbge and set the culling shape to be huge.