3 Replies Latest reply on Jul 18, 2006 6:44 AM by keogan

    Reset World problems

      Hi folks,

      I am having a small problem. I have imported a w3d file of a drumkit from max. I have set it so that when you hit the up arrow a particle system is relaeased from the crash cymbal, when you hit the left arrow, a particle system is released from the snare drum. This works fine first time but when I try to hit the arrow keys a second time I get the "Object with duplicate name already exists" I know this has something to do with the reset world function but despite my best efforts I can't seem to reset the particle systems. Any ideas?
        • 1. Re: Reset World problems
          Level 7
          keogan wrote:
          > on keyDown
          > case the keyCode of
          > 123:
          > --letThereBeLightSnare
          > --create a new modelResource
          > MyModResSnare = p3Dmember.newModelResource("myParticleSnare", #particle)

          You have to delete the existing modelResource before creating a new one
          with the same name.
          Agust�n Mar�a Rodr�guez

          www.onwine.com.ar > Macromedia Director demos & code
          • 2. Re: Reset World problems
            James Newton, ACP Level 3
            This is the problem line:

            MyModResSnare = p3Dmember.newModelResource("myParticleSnare", #particle)

            The second time this line is run, the application tries to create a new model resource, but "myParticleSnare" is already used.
            You could try this:

              MyModResSnare = p3Dmember.modelResource("myParticleSnare")
              if voidP(MyModResSnare) then
                MyModResSnare = p3Dmember.newModelResource("myParticleSnare", #particle)
              end if

            This will only create a new resource if none already exists. However, it will also mean that the particle emitter is re-initialised. You might want to have a series of particle emitters, one for each time the user hits the left arrow key. In this case, you will need to do something like this:

            property pCounter -- incrementing integer

            -- <SNIP>

              vName = "myParticleSnare"&pCounter
              pCounter = pCounter + 1
              MyModResSnare = p3Dmember.modelResource(vName)

            Now you can create a new emitter each time. The disadvantage is that the computer's RAM may fill up quickly if the user keeps hitting the left arrow key. A more robust system would be to create an Object Manager which creates objects as they are needed, keeps track of which objects are still active and recycles or deletes objects when they are no longer required.

            You will have to make changes like this at a number of places; each time you use a "new<Object>" command.
            • 3. Re: Reset World problems
              keogan Level 1
              OPenspark! you legend. I wrote to your company only the other day as my hosting company deleted all my inbox by mistake so I lost the name of the suggested contact you gave me for the drums project. He was a guy in your office with a specific interest in percussion. Would you mind dropping me a very quick line with his name again. Thank you so much. And thnks for you help with that code. I am finding this learning curve quite steep!