Forum Discussion

motorsep's avatar
motorsep
Start Partner
4 months ago

Typescript script doesn't work in VR - why?

So, I got typescript script that works perfectly fine in the Desktop Editor, in Preview, but doesn't work at all in VR (neither on desktop nor when published).

What could be the issue ?

4 Replies

  • I've run into this sort of inconsistency in behavior and had to work around it by trying different approaches 1 at a time until it worked on VR. Can you provide more context for your specific situation? The script and the behavior that is different from one platform to the next?

    edit:
    In case it helps: One of the instances that I ran into was related to how I setup at assets parent/children hierarchy. I had a structure that was:
    [0] Parent
         [1] Child (with trigger)
              [2] Another Child within that Child

    The trigger of [1] activated the Child of the Child [2]

    This worked in editor and on Mobile but NOT in VR

    I changed the structure to the following and it worked on all platforms
    [0] Parent
         [1] Child of Parent (with trigger)
         [1] Another Child of Parent

    • motorsep's avatar
      motorsep
      Start Partner

      I have the same setup that works for you (with script attached to [0]parent ). I use .visible.set() and .setVisibilityForPlayers(), and for some reason those don't seem to "click" in VR.

      • OverTheEdge's avatar
        OverTheEdge
        Member

        Are you doing the same sort of thing? That parent object with the script attached to it is a trigger? Where is the object that is being set to visible? 

        In my case, the work around may have been that the trigger object and the object being set to visible both need to be at the same level in terms of parenting hierarchy. So if the object that you are setting to visible, is a child of your trigger object, I would expect it to fail on VR if it is the same problem I ran into. 

  • Ok, figured it out - it was just code issue (replication). Now everything works in Desktop/preview and live in VR.