Object click event help

(Wakyak) #1


Trying to add a basic click event for specific objects in my project, this is what I’ve got so far:

function(info) {
if (info.instanceID = myObject) {

  	console.log('Great Success ');

{ pick: ‘slow’ }

This leads to every click, no matter which object / instanceID I click, resulting in ‘Great success’. I’m guessing I’m missing something rather basic, any hints?

Cheers /Erik

(Shaderbytes) #2

error is you only have one equals sign; change it to two or three

(Wakyak) #3

Thanks Shaderbytes!

Though I could of sworn I used every equals variant yesterday, and sure enough it didn’t work now either.

Turns out “myObject” was a Geometry group, which worked fine for showing and hiding but didn’t give me an InstanceID on the ‘click’ event, rather an instanceID of one of the geometries in the group.

After a bit of geometry reorganising all is well with the world.

Thanks again! /Erik

(Shaderbytes) #4

cool glad you got it working :slight_smile: for future reference :

Click event always returns instance ID’s of geometry nodes , not groups or matrix transforms.

For scripting
single “=” performs assignment , not comparison.
double “==” performs comparison ( not strict , implicit conversions of types can result in expected or unexpected results , like numbers converted to strings or string converted to booleans etc.)
triple “===” performs strict comparison ( object types will not be converted and are required to be the same )