Long story short,
I working on a character editor that allows you to visually place/adjust hitboxes(PhysicsNode) on an animated character.
I was using the 12-19-2010 build, and recently downloaded the 01-04-2011 build, I ran the test programs, noticed that the debug collision shape were updated, so I figured awesome, lets see how they look in my editor, to my surprise the hitboxes(PhysicsNode) were no longer attaching to the bones.
control.getAttachmentsNode(Bone).attachChild(hitbox); works beautifully with the 12-19-2010 build…follows the bone through an animation etc…but don’t work with the newest build, I’ve temporary switch back to the early build
so my question is, was this intention, or is there a new, just as easy way to attach a physics object to a bone?
if anyone can shed some light on this I’d be very grateful?
Well, before the physics objects location was constantly updated by the node object. Now physics objects are not nodes anymore. The PhysicsNode etc that are provided are now nodes with controllers and they only set the physics location when setLocalTranslation() is called directly, not when the objects location changes otherwise. Actually the fact that they did before was leading to problems in the physics anyway since the movement is not like a physics movement but like beaming the object around each frame, so it was very error prone. What you could do is set the controllers to kinematic mode and update their position each frame when you add some switch. Extend PhysicsRigidBodyControl for that and do it in updateLogicalState(), but dont forget to call super.updateLogicalState().
Thanks normen, got it working again
I’m assuming you meant extend the PhysicsNode, PhysicsRigidBodyControl doesn’t have a updateLogicalState()
if anyone else if interested…this works just as good
[java]
public void updateLogicalState(float tpf) {
super.updateLogicalState(tpf);
if(bone != null){
setLocalRotation(bone.getWorldBindInverseRotation());
setLocalTranslation(bone.getLocalPosition());
//this.setLocalRotation(parent.getLocalRotation());
//this.setLocalTranslation( parent.getLocalTranslation());
}
}
[/java]
for some reason directly getting the bones rotation and position works better than getting the parents rotation and location?
using the parent causes a weird side rotation
No, I mean PhysicsRigidBodyControl, sorry, the method is called update() and its called in the Spatials updateLogicalState()…