I have a rigid body cube. When I start the BGE, it falls and hits the ground. I have an animation that moves the cube up and then down again. When I activate the animation, the cube snaps to it’s original location before playing out the animation. Is there a way to make the animation happen from the cube’s current location? Thanks!
If you don’t want your meshes to “snap” into position when playing actions, use blendin frames.
If you want the mesh’s current location to be the object’s actual location when starting a new action, you can parent (or bone parent if using an armature) an empty to the mesh and set the object’s location to the location of the empty when starting the action (this requires a little Python). This generally isn’t done in practice though, and I can’t think of a good reason why you would do it instead of using more conventional methods to move the object.
enable the [L] button at the action actuator
I just tested: The [Add] and [L] switches seems not to work anymore
Edit2: … since 2.5x
Mobius, I think tried out what you said (see attached .blend file) but it doesn’t seem work… I’ll keep fiddling with it. There’s got to be a way to make an animation evaluated locally vs. worldly. The reason I’d like to know is that I have a game character with a Ragdoll. I can make the character run around, then when I hit D, the ragdoll takes control and he flops to the ground. I have an animation of him getting back up, but I want the animation to start from the ragdoll’s current position. The way I have it now, he snaps to a position on his back with hands at this side, but I need him to blendIn to this position from his current position. Any thoughts?
Rigid Animation.blend (471 KB)
The reason your blend wasn’t working was because your weren’t animating the cube with an armature. I’m not quite sure how to solve the issue with non-armature actions, but here’s your blend modified to use an armature. Note that you don’t need to use the empty to reset the object’s position when playing the action.
Rigid Animation Fixed.blend (483 KB)
The ragdoll issue seems a bit more complicated. I haven’t worked with ragdolls much myself, so I’m not sure I’ll be able to help you much. Could you explain a bit how you transition between the armature controlled mesh and the physics controlled one? I assume you’re swapping out objects.
Thanks Mobius! Like you said, the ragdoll is a bit more complicated so I’ll need some time to figure out how to apply what you showed me.
As for your question, the ragdoll pieces are parented to empties that are parented to each bone in the armature. Thus, the ragdoll pieces follow the armature. When death occurs, the ragdoll pieces are deparented, allowing them to fall… The ragdoll pieces have an IK empty and Pole target empty parented to them. Each bone in the armature has an IK constraint set to influence of 0. When death occurs, I use an armature actuator on ‘Set Influence’ to make the constraint influence set to 1. This makes the bones follow the IK and Pole targets. Coming back to life is a reverse of the death process. I plan to make a tutorial on this topic when I’ve worked out the kinks.
I can make a rag doll,
I can make a better one if some one helps me write a physical track(torque) to (then apply force) for rigid body Ik
So Rigid bodies all linked with 6dof definitions (NOT PARENTS) and then using a “Force map”
you can walk etc
it’s complicated, but worth it in the end I think, as you can make new animations with just code, and not new .blends etc
I had him do push ups @ one point but balance was more then I could tackle so I switched the core back to dynamic until I can wrap my head around it,
RunFast.blend (1.95 MB)
It seems to me like you basically have two options:
Move the bones to match the ragdoll position before playing the get-up action.
Parent the ragdoll objects back to the empties, but instead of moving them back to their original positions immediately, smoothly move the pieces of the ragdoll to match the bone positions before or as the get-up action is playing.
Since moving bones without actions in the BGE isn’t possible as far as I know, you’ll have to resort to option 2. The easiest way would be to use Python. Have a list of all main objects that compose the ragdoll, and for X frames, move each object 1/X of the distance to their parent empty. You could use an alternate function instead if you want the transition to be interpolated in some other manner instead of just being linear.
Unfortunately this could result in the mesh moving really unnatural ways depending on the position of the ragdoll. Right now I can’t really think of a simple solution for this.