2 Replies Latest reply on May 15, 2007 2:03 AM by biiin

    resetWorld() problem

    biiin
      Hi!
      Using the reset world for...ehm..reseting a world. Then i get a "shockwave has generated an error and stopped to play.." This is used in a runiture demo, reseting is used for getting back to the origin in case the user gets lost in their navigation of the chair.
      Should i use a diffrent type of command instead?
        • 1. Re: resetWorld() problem
          duckets Level 1
          Yes, because if you are storing references to objects in your current scene, resetting the world will break those references.

          If you want to reset an object back to its original transform, you need to store its original transform when the scene starts. You could use the object's "userData" property to store this. Eg:

          myObject.userData.setaProp(#originalTransform, myObject.transform )

          And subsequently, to reset the object to its original transform:

          myObject.transform = myObject.userData.originalTransform

          Hope this helps!

          - Ben
          • 2. resetWorld() problem
            biiin Level 1
            Hi Ben!
            And thank you for your replay!

            I use this code in the first frame :
            member("test").model("svart").userData.setaProp(#originalTransform, member("test").model("svart").transform )

            (test is my world and svart is the model (black in swedish).

            And to return to start pos:
            member("test").model("svart").transform = member("test").model("svart").transform.userData.originalTransform
            Then i get a script error, access not supported #userData.

            Any ideas?