How to code - Do command ONLY when raycaster targets object AND a button is pushed?


Hello! I really need some quick advice. I’m rewording this in hopes the problem will be clearer. We really need and would appreciate any help anyone could give as soon as you can.

We have a ghost game where we want to destroy a ghost when two conditions are met: a Raycaster is pointing at the ghost AND a button is pushed.

We have the Raycaster working and interacting with the ghost. The button will destroy the ghost. However, we need to know how to set up the conditional IF the Raycaster is targeting AND the button is pushed.

Please help!


Hi @donnav,

This sounds like a really cool idea.

What it sounds like you need is a boolean value which is set to false, until the ghost is being looked at, when it is then set it to true. You can then check to see if this value is true when the button is pressed, and if it is, kill the ghost.

I’d recommend checking out our typescript primer documentation to get some tips!

Hope this helps.



Hi, George!

Thanks for the help. I basically live in your script documentation, but some aspects of the language are extremely challenging and that’s why this forum is so valuable.

Can you help me with another few specific problems? I have tried for days to figure out solutions but no luck.

a. how could I make an object, a plane, leave a bezier path and move from it’s current location to the user/phone screen? I know you can access the position as an array, but I do not know how to make it travel from that location to the user position.

b. I am using the World Tracker subsymbol. How can I get the experience to pause loading until after the ground is placed? I have tried adding a variable to the World Tracking module that changes from False to True after placement, but this value does not seem to be exporting to the main program even though I am using Export Let.

Thanks in advanced


Hey guys. Am I doing something wrong in posting? I don’t seem to be getting any replies. Are my questions poor?


Sorry had a lot going on. Here is a zpp file that should help.
I have add a symbol.emit(“custom:placed”); to world tracking. When you press the place button it will be emitted. From the main symbol I’m looking for the emit to start the bezier.

Next I had added a group to the bezier and one group set to Then setup a timeline that will move from bezier to camera group. The green button runs the timeline. red will reset.

FYI you may have to play with your model to make it move niceley. my demo it flips and jumps in size as it moves.

Bezier Ghost Game.zpp (3.7 MB)


Not at all :slight_smile:! It can just be a little slower over the weekend in general - particularly in terms of posts from our internal team, as our offices are only open Mon-Fri.

Hopefully Steve’s come to the rescue!