2 Replies Latest reply on Jan 25, 2007 4:44 AM by mbrown174

    Simple Collison Detection - Whats Wrong

    mbrown174
      Hello
      Im doing a simple tour for my coursework and am using simple collision detection using Lingo's built in collision modifiers. The collision works - its just that when the objects collide, the movie should jump to a new frame with the label - 'movie1'
      Can anyone see what I'm doing wrong? Thanks in advance for help!
      on beginSprite me
      sprite(me.spriteNum).member.resetWorld()

      -- lock camera to character
      sprite(1).member.model("Character").addChild(sprite(1).member.camera[1])
      -- get a reference to the camera
      pCamera = sprite(me.spriteNum).camera

      -- turn fog on
      pCamera.fog.enabled = FALSE

      -- recognize but near and far
      pCamera.fog.decayMode = #linear

      pCamera.fog.near = 5000
      pCamera.fog.far = 8000
      myModel = sprite(me.spriteNum).member.model("Character")

      myModel.addModifier(#collision)
      sprite(me.spriteNum).member.model("Character").addModifier(#collision)
      sprite(me.spriteNum).member.model("University").addModifier(#collision)

      -- set all collision detection to #mesh
      myModel.collision.mode = #mesh
      sprite(me.spriteNum).member.model("Character").collision.mode = #mesh
      sprite(me.spriteNum).member.model("University").collision.mode = #mesh


      -- set callback for collisions
      sprite(me.spriteNum).member.registerForEvent(#collideAny,#handleCollision,me)

      end

      on exitFrame me
      if keyPressed(123) then -- left arrow
      sprite(me.spriteNum).member.model("Character").rotate(0,10,0)
      else if keyPressed(124) then -- right arrow
      sprite(me.spriteNum).member.model("Character").rotate(0,-10,0)
      else if keyPressed(125) then -- down arrow
      sprite(me.spriteNum).member.model("Character").translate(0,0,20)
      else if keyPressed(126) then -- up arrow
      sprite(me.spriteNum).member.model("Character").translate(0,0,-20)
      end if

      on handleCollision me, collisionData
      go to "Movie1"
      end