How to stop armature animation at any point and start seeking steering in same frame?

Problem: Animation and steering works fine but not in same frame.
When steering seeking start, it restarts from the first frame of animation

I tried and solved this in new simple blender file but my main file problem continues. Can it be armature and how i can solve this?

To stop the animation with logic-bricks.

  • Create a empty animation data-block, then play that empty animation whenever you want the animation to appear blank/reset.
    A animation will still be playing, just no visual movement.

To stop the animation with BGE API.

KX_GameObject.stopAction()

To start the Steering actuator with logic-bricks.

  • You can do this multiple ways.
    Either with Message sensors/actuators, or a Actuator sensor to check if the blank animation mentioned above is still playing or not.

To start the Steering actuator with BGE API.

  • Use the following rough-draft code to check if a sensor is still active, if so, stop the animation and start the Steering actuator.
    Note: This code is built for module controllers, not script controllers, you can tweak it easily for either tho.
import bge

def function(self):
  if self.sensors["Input"].positive:
    self.owner.stopAction()
    self.activate("Steering Actuator")
2 Likes

I will try for this. Thank you!

1 Like

I don’t get what i need. It stops but what i need is it will continue another action without resetting. It should resume to new action where it is.

My theory is this: mouse armature has radius center and when mouse moving it’s action, radius stays there, not moving. I think this is why new action of mouse armature starts from that radius point.

So if we can set that radius point stick to mouse moving, i guess my problem will be solved. But i dont know how to do it. Do you know how can i set radius with mouse?

It should be stuck for every different frame.
Radius centre = Object geometrical centre

So you want anim_2 to copy anim_1’s current frame-time?

  • Create a game-property, I’ll call it Anim_Pos.
  • Use the following code to copy the current anim time to the game-property.
self.owner["Anim_Pos"] = int(self.owner.getActionFrame())
  • Play anim_2 at anim_1’s animation frame position.
self.owner.playAction(int(self.owner["Anim_Pos"]), end_frame, layer=0, priority=0, blendin=0, play_mode=KX_ACTION_MODE_PLAY, layer_weight=0.0, ipo_flags=0, speed=1.0, blend_mode=KX_ACTION_BLEND_BLEND)

Not without some complex math operations for cursor-depth calculations.
I suggest instead have a large fake dummy collision-proxy for any objects that are select-able.

1 Like

If i think what you mean, then:

  • select the armature
  • go to edit mode
  • press A to select all
  • hit Shift+S -> cursor to selected

Now the 3d cursor should be at the center of your armature/mouse

  • go out of edit mode
  • make sure you have armature selected
  • hit Ctrl+Shift+Alt+C -> origin to cursor

Now the orange dot is back where it belongs, in the center of your armature/mouse.

#edit

Ok looking better at the topic, copy the animation frame like @RandomPerson said but instead of self use cont.

or simply use and see it as a game character:

  • add a cube
  • place the armature+mouse inside it
  • make the box fit the mouse
  • parent the armature to the box
  • animate the BOX for the path it needs to walk
  • animate the ARMATURE with an running animation.
  • set armature and mouse mesh to no collision
  • set the box to dynamic
    – the box holds the moving logic, walk run jump etc and path animation bricks
    – the armature holds all the logic for animations for the mouse, walk cycle/run cycle/etc. nothing else just animations the mouse needs to do

Now all the problems are solved for sure

1 Like

Good idea, i tried this but this is being correct when mouse moves linear direction. My mouse armature is also rotating. And when it is rotating, seeking actuator acts like mouse is an object, not an armature. So mouse sometimes seeks from tail, sometimes seeks from head according to situation of armature.

Do what i said in below the #edit, that works for 100%

box = seek object, object you gonna move when it needs to walk, so all seeking and movement bricks on the box.

mouse = just representation of a mouse nothing more with a walk or run cycle.

1 Like

I will try. Sounds possible. Thank you for advice :+1:
I will feedback soon.

Would you by any chance be willing to upload your blend. file so we can take a look at what’s going on? If not, that’s totally fine!

I actually might have found a solution. I was just experimenting.
I’ll give exact details on what I did, but for now, animating the armature in the pose mode will keep the origin in the same place it was in object mode, but when you animate the armature in object mode, the origin should move with the armature.
What I did was I animated a walk in place action in pose mode; then I animated the movement action in object mode (both animations were done on the armature). Animating in object mode ensures that the origin stays with the armature. It might feel ridiculous at first because with the animation in object mode, all of the bones are static, and moving as a whole, but in the end it worked.
Next, this is what I did with the logic bricks


I put in a boolean property and named it near. Basically, I played both the walk-in-place animation and the movement animation at the same time. NOTE: in my experimenting, I found that it is important that your walk-in-place action and your movement action both have the same start/end key-frame numbers (My walk animation was only 25 key-frames while my movement was 100, so I had to duplicate the walk animation 4 times so that it could end at 100 key-frames.)
Then, whenever you trigger the boolean to be true (You can do whatever you want to trigger it.) the mouse will immediately start seeking the human (also notice that I had it playing the walk animation, even while it was seeking the “human”).

I really hope that helps!! I you have any questions, please ask them; there might be a delay in my response though.

1 Like

By #Cotacks i solved my problem. But i want to thank you for your detailed reply. :pray:

1 Like

It worked! Thanks a lot!

2 Likes

Sure, always glad to help! I’m glad I found a solution because I’ve had problems with this before as well.

1 Like