Click (and touch) event on objects

I am new to playCanvas (and 3D) so forgive me for this silly question.

In flash (or canvas) we have objects with unique id and we set events (click, touch etc) by writing something like this:-

this.btn1.addEventListener("click", fl_BtnHandler1.bind(this));
function fl_BtnHandler1() {
	//your action here

I have a scene where when we click on individual plane or cube some event happens.

I found out this link but this is not working.

can anybody please help me here.


You have to post the project link, not published build link.
It is very likely that camera script that does orbiting prevents mouse events from propagating.

This is editor link (I think ).

I have disabled all other script and tried; but it was still not working.

Scripts you’ve copied are legacy script system, and not what you want. Here is tutorial project that you should use:

There are also quite a few other tutorial samples about picking objects here:

1 Like

Thanks for quick reply. The new scripts working fine.

Another question, is there any option for giving ids to object and then referencing them in the scripts.

Basically I need is to click a ‘button’ and another object become visible/invisible.

Use Script Attributes with type “entity”:
Please feel free to use a lot, as it has loads of useful info and learning material. It is faster to look and learn yourself than wait for others to answer your questions. And learning - is essential skill for developer.