ReferenceError: Touch is not defined

I am trying to add basic functionality on from tapping a mesh on-screen. I have set up my Space to look and work exactly like the “Studio: Detect Object Type On Tap” Sample Project from Jessica Sheng.

As far as I can tell, every single thing in my project is apples-to-apples. But no matter what I do, any time I tap/click anywhere on the screen, I get an error that says “ReferenceError: Touch is defined”. Can someone help me troubleshoot this? What are some of the first things I should be checking and verifying?

Happy to provide any code samples/screenshots as requested.

Thank you

I can take a look. Can you land your changes and share the project with the support workspace?

Sure! Thank you. Done.
You can find the main relevant script GoToPanelsOnTap on the TouchManager object. If you want it to be true 1:1 the Camera should be 3D instead of World AR. All I want to do is change Spaces when you tap on the maneki neko.

Could you let me know the name of the project? I’m having trouble finding it. :slight_smile:

Hi @GeorgeButler , the project is called sawtelle-stories-interactive and the Space in question is called Tsujita-ManekiNeko, which I have set to being the Entry Space for now.

I have great news for you, we can simplify this a ton!

import * as ecs from '@8thwall/ecs'

const GoToPanelsOnTap = ecs.registerComponent({
  name: 'GoToPanelsOnTap',
  // TODO: enable maneki neko on meshfound/locationfound
  // https://www.8thwall.com/docs/api/studio/events/xr/vps/
  stateMachine: ({world, eid}) => {
    ecs.defineState('go-to-panels')
      .initial()
      .listen(eid, ecs.input.SCREEN_TOUCH_START, () => {
        world.spaces.loadSpace('Yamaguchi-Panels')
      })
  },
})

export {GoToPanelsOnTap}

All I had to do was put the component on the cat and it works as expected. PS: You probably want to move the Maneki Neko object to be a child of the VPS location. If you don’t then it won’t anchor to the location or show up when you scan the location with your phone.

Perfect, thanks so much @GeorgeButler . I figured it could be that simple, but I am still getting the hang of this API.

Two follow-up questions:

  • I did the reparenting you described, but now for some reason I can’t see the Maneki Neko in the Play Mode, even though clicking on it does the desired screen transition. Any idea why?
  • I am still getting spammed with ReferenceError: Touch is not defined messages in the console any time I touch the screen. This includes after I have switched to the new space. How do I get that to go away?

Thanks again!

Oh, I see, now that it’s parented to the VPS it will only show the Maneki Neko when the location has been found. I figured that out with the debug controls. Cool!!

The question about the input error spam still remains, though.

I’m not seeing the touch error in the project. I do see this error however:

Are all your changes landed?

This topic was automatically closed 4 days after the last reply. New replies are no longer allowed.