Says "Play" has no definition in my animation code

Here is my code… I can’t imagine what’s causing the error…
var modelCharacterURL = “Models/CuteAlienPlayer/scene.gltf”;
var modelCharacter;

var loader = new GLTFLoader();
loader.load( modelCharacterURL, gltf => {
modelCharacter = gltf.scene;

			scene.add(modelCharacter);
			
			// a second smaller model
			const clip = gltf.animations;
			mixer = new THREE.AnimationMixer(modelCharacter);
			
			const floatingClip = THREE.AnimationClip.findByName(clip , 'Armature|ArmatureAction_Object_6');
			const floatingAction = mixer.clipAction(floatingClip);
			floatingAction.play();
	    	
			
		}	);

The error that comes up says that "Play is not defined’:

Console log the value of gltf.animations and see if the animation is there with exactly the name you’re attempting to fetch it by.

Blender strips some special characters from animation names, so instead of Armature|ArmatureAction_Object_6 it could be called ArmatureArmatureActionObject6 etc.

1 Like

animations is an array use animations[0] after console logging as @mjurczyk has suggested

maybe you can check your model in threejs editor and see the animation names.

Thx for the solutions…turns out that I updated it to often, and the code was backwards too