[SOLVED] pc.events.attach is gone in version 2.1.0

I have been using pc.events.attach(myClassInstance) for my projects to listen to some events from pc or custom events I created, but after upgrading Playcanvas to version 2.1.0. It doesn’t seem to work and I noticed whole pc.events is gone. Is there any alternative to do the same thing?

Thank you,

Extend from EventHandler or create an instance to use in the class engine/src/core/event-handler.js at 1585f01029641789dab8e06200854d036caa169e · playcanvas/engine · GitHub

Or you can re-add the logic that it used to do it yourself: engine/src/core/events.js at 36c482649b938188417ea9151f4af37ff26e12a0 · playcanvas/engine · GitHub

1 Like

A post was split to a new topic: SketchFab asset store isn’t working

Is tween.js no longer supported in PlayCanvas Engine v2.x?

When trying to use tween.js in my PlayCanvas project, I encounter the following error:

Uncaught TypeError: Cannot read properties of undefined (reading ‘attach’).

The relevant code snippet is:
pc.events.attach(this);

To verify that the issue is not specific to my project, I tested it using the official PlayCanvas tutorial for Tween.js and encountered the same error:
https://playcanvas.com/project/452634/overview/using-the-tween-library
This raises the question: Is tween.js no longer supported in PlayCanvas Engine v2.x, or has its implementation changed?

Apologies we are still in the process of updating all of our supporting libraries to support Engine v2. I would recommend staying on Engine v1 for now and we will update you once Tween is compatible with Engine v2.

We have a PR available for this, so should be able to update this soon

1 Like

@jro The playcanvas-tween library has been updated now to work with V2. You can either grab the latest from the repo or import it again from the asset store. Drop me a message on Discord if you’re having any issue

2 Likes

Mark, I really appreciate your quick response and the fix. It works perfectly—thank you!

2 Likes

No worries! Thanks for flagging it :smiley: