# Adding animation (using AnimationFactory ) to physical Node

Hey,
I have physical object and everything works well until I add to it animation. After it it’s not rigid anymore, and other objects can go through ir, here is the code how I add animation. Do you have any suggestions how to make it rigid? Or what is the problem?

``````    float[] knots = {0.0f, 0.4f, 0.5f, 0.9f, 1.0f };

// Transform[] transforms = new Transform[knots.length];
Transform[] transform = new Transform[knots.length];
transform[0] = new Transform(new Vector3f(0.0f, 2.0f, 5.0f),
new Quaternion(0.0f, 0.0f, 0.0f, 1.0f)    , Vector3f.UNIT_XYZ);
transform[1] = new Transform(new Vector3f(0.0f, 2.0f, 200.0f),
new Quaternion(0.0f, 0.0f, 0.0f, 1.0f), Vector3f.UNIT_XYZ);
transform[2] = new Transform(new Vector3f(0.0f, 2.0f, 200.0f),
(new Quaternion().fromAngleAxis(FastMath.PI, new Vector3f(0, 1, 0))), Vector3f.UNIT_XYZ);
transform[3] = new Transform(new Vector3f(0.0f, 2.0f, 5.0f),
new Quaternion().fromAngleAxis(FastMath.PI, new Vector3f(0, 1, 0)), Vector3f.UNIT_XYZ);
transform[4] = new Transform(new Vector3f(0.0f, 2.0f, 5.0f),
(new Quaternion().fromAngleAxis(2*FastMath.PI, new Vector3f(0, 1, 0))), Vector3f.UNIT_XYZ);

// Time duration for the animation
float animTime = 30;
// Frames per second for the animation
int fps = 60;
AnimationFactory animFactory = new AnimationFactory(animTime, "OtoPath", fps);

for (int i = 0; i &lt; knots.length; i++) {
// Add the knot to the AnimationFactory

}
// Build the animation
Animation anim = animFactory.buildAnimation();
// Create control for the spatial animation
AnimControl control = new AnimControl();
// Hashmap of available animations
HashMap&lt;String, Animation&gt; animations = new HashMap&lt;String, Animation&gt;();
animations.put("OtoPath", anim);
control.setAnimations(animations);
// Add control to target spatial

// Create channel for the animation, that enables us to play the animation
AnimChannel channel = control.createChannel();
channel.setAnim("OtoPath");
channel.setLoopMode(LoopMode.Loop); [/java]
``````

and this is the node itself

Oto.move(new Vector3f(0, 2, 5));
CollisionShape shape = CollisionShapeFactory.createDynamicMeshShape(Oto);
[java]

What do you mean by rigid? Because I don’t think it means what you think it means…

I mean before I added animation to Oto, physical Node could not go through it, there was collision, one object pushed another and so on. after adding it, physical object is not colliding with it, and it can go through it. The most interesting part is that I have enabled to see physics doing

bulletAppState.getPhysicsSpace().enableDebug(assetManager);

and I see how collision shapes go through each other, but it was not so before adding animation

never used the AnimationFactory, but if it’s just a Spatial animation, then you can set oto’s RigidBody control to kinematic

Thanks for advice, Here is what I did

CollisionShape shape = CollisionShapeFactory.createDynamicMeshShape(Oto);
RigidBodyControl rb = new RigidBodyControl(shape, 1);
rb.setKinematic(true);