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:

https://playcanvas.com/editor/scene/1533884

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: https://github.dev/playcanvas/engine/blob/005871dc5ec721af3cd5ecb5c804e3ad98f7319b/src/framework/components/animation/component.js#L653-L654

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

https://playcanvas.com/project/984833/overview/f-demo-of-issue

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

https://playcanvas.com/editor/project/983619

Ah, looking at your project, the other way to workaround it is to disable the Model Component with type Box: https://playcanvas.com/project/985199/overview/f-demo-of-issue-2

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