Parenting a camera

Hello, I am running into issues parenting a camera to bone animation. I have used this method in the past but is currently giving me errors related to missing children. Has anything changed with the new updates to entities that may be causing this targeting issue?

link to method that did work: Entity | PlayCanvas API Reference

what exact issues are you running into?

Well, I can say that this method currently will not work unless the parent entity that holds the animation has a “Model (legacy)” component added to it. You will not see the animation in the editor either unless you add a Model (legacy) component and change the Type to anything but Asset.

method from a couple years ago: How to attach a camera to an animation object

Can you post a project that shows your issue please?

1 Like

Hi there, here is a test project demonstrating the issue:

So here we have two entities with animations associated - in the Root is a script which grabs an entity, looks for a specific bone in the entity, and grabs an element to reparent to that bone. In this case, it is the camera.

One of these entities has a model associated (a box) and one does not. The reparenting only works with the entity with the model.

1 Like

Hi @davemc and welcome,

I’m thinking animation playback may be tight to a mesh being present and referencing that skeleton. Most likely there is a dependency somewhere that is responsible for that. @mvaligursky @Elliott any idea?

In the meantime your trick to have a model/render component to trigger the animation is good. You can add this line in a script of yours to remove the box from rendering:

this.entity.model.meshInstances[0].visible = false;

Good shout @Leonidas

Looks like the legacy animation component only updates if there is a model component on the entity:

I don’t know a way around this but the Anim Component doesn’t have this problem

1 Like

So, I found a solution to getting the results I was after by adding a camera component to an animated entity. PlayCanvas | HTML5 Game Engine

Ah, looking at your project, the other way to workaround it is to disable the Model Component with type Box:

Another small question - the naming convention of “legacy” for animation and model components; does this signify any planned deprecation or are these components relatively stable for the foreseeable future?

Those legacy components will not get any new features but we will fix bugs as people encounter them. We are unlikely to remove them until engine 2.0.0