Tween no longer works on graph nodes within a model component

Hi all,
I was updating an old project to resolve the issues with basis library on iOS. In the process, it looks like the old version of tween isn’t compatible with the new version of playcanvas engine, which makes sense since it’s been a few years now. After updating the tween library to the latest, it looks like that if I find a graph node within an entity using the model component, I can no longer use twwen with it. Here is an example of what I am talking about:

const targetNode = meshEntityWithModelComponent.findByName("targetNodeWithinTheMesh");

targetNode.tween().to()
// The execution above results in:
// targetNode.tween is not a function

I am guessing something got updated that restricts us from doing this anymore? If so, I can start the work on updating everything to use render component instead but would like to know if any quicker solutions are possible for now?

I didn’t provide a test project for this yet. But for any reason if that is required, I could create one as well. Any help would be appreciated :slight_smile:

Hi @Tanay_Dimri and welcome back!

Did you get any errors? If so, it might be helpful to share.

Please read the topic below to make the tween library compatible with the current engine version.

2 Likes

Hi @Albertos
Thanks for your quick response. I had already updated the changes recommended in that thread (mostly related to the deprecation of the usage of “complete”, “update” events). Unfortunately, the issue in my case seems to be something to do with the scene hierarchy, or at least that’s what I could narrow it down to.

Here is a screenshot of the error I get

In the screenshot above:

  1. this.meshObject, is a node found within a GLB asset that is loaded using the “Model (Legacy)” component.
  2. AnimateCupHolder, is just the script file that has a “run” callback, which executes on annotation clicks.
  3. Animator.run, is the method that calls the “run” callback mentioned above.

There are other object being animated in this scene which are loaded via separate fbx files and they seem to work as expected. It’s only the objects within an asset that are fetched using “entity.findByName()” that don’t seem to work with tween. I logged the object found using .findByName within an asset, it did not have the tween attached to that object anywhere.

For now, I have updated the scripts to run an app level tween, then setting those values to these graph nodes within the asset. It seems to work for now and if “Render” component is the way to go forward, future projects shouldn’t have this issue.

I hope this provides enough context of what I was trying to do and where it was failing? I would have created an example scene but unfortunately things are very busy at the moment before we go into code freeze for the year.

Once again, Thank you so much for your suggestions It gave me the idea that finally solved this for now.

1 Like

Make sure:

  1. The tween library is set to Preload in Editor, under asset proeprties.
  2. The tween library is loaded before any of your scripts in the project settings scripts loading order.
2 Likes

Hey @LeXXik
Good points!! Both are true in my case. That’s why I was more confused as to why this is happening. At some point I would like to create a test scene where I access an internal graph node within an asset loaded via the model component and see if the issue still exists.