3 Replies Latest reply on May 8, 2006 4:21 PM by mbrown174

    Model Reset - Please help!

    mbrown174 Level 1
      I've just applied impulse to a model called 'bullet2'
      How do i reset the model back to its earlier position?
      Thanks
        • 1. Re: Model Reset - Please help!
          PpHammer Level 1
          You could store the initial data of your object before applying a impulse (or any other transforms) and use that info to restore/reset your model.

          You can use member("yourmembername").resetworld() to reset your 3d member completely. This will reset ALL objects in your 3d member. I don't know if there's a possibility to reset a single object only.
          • 2. Re: Model Reset - Please help!
            Pelleyoo
            I think you should create a variable pStartPos. Then you can do something like this;

            on beginsprite me

            pStarPos = member("w3d").model("bullet2").worldposition

            end

            then when you want bullet to return to its original position you can do something like this;

            if returnposition = true then
            member("w3d").model("bullet2").transform.position = pStartPos
            end if


            Sucker. ;P
            • 3. Re: Model Reset - Please help!
              mbrown174 Level 1
              Thanx guys - but I've tried the methods and I cant seem to get them to work. Director keeps flinging errors at me!

              Heres my code...
              property pHavok, pMember, pCar, pAsteroid, pBullet,

              on beginSprite me
              startTimer
              -- create backdrop texture from bitmap
              backdropTexture2 = sprite(me.spriteNum).member.newTexture("my backdrop2", #fromCastMember, member("backdrop"))

              -- add backdrop to world
              sprite(1).camera.addBackdrop(backdropTexture2,point(0,0),0)
              -- get the member for easy reference
              pMember = sprite(me.spriteNum).member

              -- reset the world
              pMember.resetWorld()

              -- get reference to havok member
              pHavok = member("Dungeon Physics")

              -- start havok at scale of 1
              pHavok.initialize(pMember,1000,1000)

              -- add mesh deform to all models
              pMember.model("bothweapons").addModifier(#meshdeform)
              pMember.model("bullet2").addModifier(#meshdeform)

              pMember.model("Enemy4rotatedagain (1)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (2)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (3)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (4)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (5)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (6)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (7)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (8)").addModifier(#meshdeform)
              pMember.model("Enemy4rotatedagain (9)").addModifier(#meshdeform)


              sprite(1).member.model("bothweapons").addChild(sprite(1).member.camera[1])


              pCamera = sprite(me.spriteNum).camera
              -- assign mass to car
              pCar = pHavok.makeMovableRigidBody("bothweapons",100,TRUE,#box)
              hpRigidBody1 = pHavok.makeFixedRigidBody("Level8side55 (1)")

              hpRigidBody31 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (1)",100000,TRUE,#box)
              hpRigidBody32 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (2)",100000,TRUE,#box)
              hpRigidBody33 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (3)",100000,TRUE,#box)
              hpRigidBody34 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (4)",100000,TRUE,#box)
              hpRigidBody35 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (5)",100000,TRUE,#box)
              hpRigidBody36 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (6)",100000,TRUE,#box)
              hpRigidBody37 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (7)",100000,TRUE,#box)
              hpRigidBody38 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (8)",100000,TRUE,#box)
              hpRigidBody39 = pHavok.makeMovableRigidBody("Enemy4rotatedagain (9)",100000,TRUE,#box)
              pBullet = pHavok.makeMovableRigidBody("bullet2",100000,TRUE,#box)
              end

              on exitFrame me
              if the key = RETURN then
              pBullet.applyImpulse(vector(0.10, 0.10, -5000000000.10))

              end if

              -- if arrows pressed, apply angular impulse to turn
              if keyPressed(123) then
              pCar.applyImpulse(vector(-1000000,0,0))
              end if
              if keyPressed(124) then
              pCar.applyImpulse(vector(1000000,0,0))
              end if
              if the key = BACKSPACE then

              end if

              -- set the physics simulation
              pHavok.step()



              end


              on mouseEnter me
              cursor 0
              end

              On backspace I want bullet2 to return to its former position
              Any pointers? Thanx for the help!