2 Replies Latest reply on Aug 4, 2006 4:08 PM by JustStupid

    havok collision detection problem

    JustStupid
      Hello everyone,

      Been posting a few problems recently some of which I found my answers myself after a bit more thinking. So promise this will be last one for a while anyway!

      I'm using havok via importing the havok physics scene into the cast [non hke] and trying to add collision detection to my complex model (a castle!) and well its not really doing anything my characters can still walk through the walls, but there are no errors as well so I can't see where I'm going wrong

      Heres the code I have.

      on beginSprite me
      myHk = member("havok")
      myMember= sprite(me.spritenum).member
      myTolerance = 4.0 -- usualy only 10% of worldscale
      myWorldScale = 1 -- inches (1 inch = 0.0254 metres [use 1.0 if world is designed using Metres]
      myGravity = vector(0, -9.81, 0) -- for 1.0 metre scale, use vector(0, -9.81, 0)
      myHk.initialize( myMember, myTolerance, myWorldScale ) -- set it up
      myHk.gravity =myGravity
      -- used by the step() function in the exitframe
      myTimeStep = 0.04 -- 1/25.0 i.e. 25 fps
      mySubSteps = 5 -- used by havok to calculate between time steps

      mlist = ["castle","water", "knight", "whiteknight"] --this is a list of model-numbers I want to apply physics to

      player = myMember.model("knight")
      player.addModifier(#meshDeform)
      prb = myHk.makeMovableRigidBody("knight",100,true,#box)

      player2 = myMember.model("whiteknight")
      player2.addModifier(#meshDeform)
      prb2 = myHk.makeMovableRigidBody("whiteknight",100,true,#box)

      m = myMember.model("castle")
      m.addModifier(#meshDeform)
      myHk.makeFixedRigidBody(m.name,false)

      m = myMember.model("water")
      m.addModifier(#meshDeform)
      myHk.makeFixedRigidBody(m.name,false)
      end

      on exitFrame me
      myHk.step( myTimeStep, mySubSteps ) -- advance the simulation

      --Down
      if keyPressed(125) then
      player.translate(0,-5,0)
      end if

      --up
      if keyPressed(126) then
      player.translate(0,5,0)
      end if

      --left
      if keyPressed(123) then
      player.rotate(0,0,5)
      end if

      --right
      if keyPressed(124) then
      player.rotate(0,0,-5)
      end if
      end

      on endSprite me
      myHk.shutdown() -- Tidy up, i.e. remove it from memory
      end

      Any ideas of what could be going wrong? Can havok be applied to complex models?

      Cheers in advance for any suggestions!

      Brenden