World Placement trigger event on placing object

Hi,

Is there any way I can get a trigger of when the user presses the “place” button for the World Placement sub-symbol? I think the only way for now is to actually edit the symbol itself, but I am wondering if there is a way to get a trigger from the main scene.

Hi @bchung2017,

Great question.

You can do it a couple of ways. You can either emit a custom event from within the subsymbol, this would mean going in and editing the subsymbol itself, or, you can listen out for when a state is activated within the subsymbol, from a script within the main symbol.

Lets go with the latter:

For the world tracking subsymbol specifically, it has a few states / stages that it goes through:

Initial - default starting state
Install - checks if world tracking is supported
User Move - looping animation asking user to move their device to find a ground plane
Placement - ground plane is found and content is shown
Normal - user has tapped place and content is anchored to that position

You want to listen out for when the normal state is active (only active once the user has tapped the place button). You can do it like this:

const World_TrackingGroundPlacement = symbol.nodes.World_TrackingGroundPlacement;

World_TrackingGroundPlacement.controllers.states.elements.Normal.on("active", ()=>{
    //Do something
});

Simply add you functionality in the event handler and it’ll run as soon as the user has tapped the placement button.

I hope this helps, let me know if you’d like me to clarify any of the above.

George

2 Likes

Wow that clears up a lot! I didn’t know I could listen for states externally. I will try this out and thank you!