Attach Camera to imported animation

I have been searching this on the forum and could not find a clear and “easy” solution for this.
So I understand that you can not directly animate your camera or import an animated camera.
You have to animate a bone then export that and use that animation in playcanvas.

Making the camera the child object of the bone is not working. I understand that I need a script for this. At this point it is not clear for me what to write. I saw some projects on the forum which I tried to replicate but did not succeed.

Lets say my animated bone model is called: “Bone” then what do I put in the script?
Its unfortunate that there is not such an example in the tutorials section of playmaker.

Hope someone can help me out.

Hi @Maarten_deVries,

Why attaching the camera to a bone doesn’t work?

All bones are pc.GraphNode instances, you can find them by their name and get their position/rotation and use it to have your camera follow the animation:

var boneNode = myEntity.findByName('Bone');

Here is an example I’ve found doinf a forum search:


thanks for explaining but I still can’t get it to work.
I have attached some screens from my project.

“Bone” is the animated bone exported from Blender.
“Camera” is the original camera from playcanvas where I attached the script to.
This is what I placed in the script (2nd picture).

Now if I run this project I get this error:

[followObject.js?id=46251105&branchId=e1a45856-2208-49ef-9298-97a911542295:2]: Uncaught ReferenceError: myEntity is not defined

Hi @Maarten_deVries,

You should adjust my code to your project, for example where do you define myEntity? Same for camera. Also move line 2 inside the initialize method.

Check the script in the code example I’ve posted. If you still have trouble, try posting a url from your sample project.

thank you. There is something in this project that I don’t get. The “characterMedium” has a “nodeName” called “LeftHand”. In the project I can’t find anything called “LeftHand”. Where is this located? Is it a bone in the character? If yes. How can I locate it in the scene?

Hello @Maarten_deVries! Currently you cannot see all nodes of a character in the scene of your project. A new feature is coming up that makes it possible to see all nodes of a character in the hierarchy. Right now you can only access this node in your script by using findByName().

I found the “Left Hand” by opening the animation file in the viewer.

Very interesting. Would it be possible to do the opposite effect? that is, that a bone can copy the data of an external entity such as its rotation