[SOLVED] Best way to add attributes to an entity in the editor?

Hi,
Is the best way of adding attributes to an entity to create a script or is there another way?

My example is this: I want to mark only certain entities in a scene as being able to be grabbed. I thought about simply adding a place holder script called “grabable” which I would add to entities and then test for it using

if (entity.script.grabable) {
  //then whatever
}

is that the best way?

In that particular use-case it’s best to use Tags. Just add the ‘grabable’ tag to the desired Entities in the Editor and then you can get them by script:

http://developer.playcanvas.com/en/api/pc.Entity.html#tags

1 Like

That works great, many thanks

I used:

if (entity.tags.has('grabable')) {
  //do whatever
}