IsCollisionBetween

From MaratisWiki
Revision as of 17:39, 11 April 2012 by Vegas (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Example 1 : On collision between two objects, display "Collision detected" in maratis console window.

   object1 = getObject("object1") 
   object2 = getObject("object2") 
   function onSceneUpdate()
       if isCollisionBetween(object1, object2) then print("Collision detected") end
   end

Example 2 : On collision between two objects, play a sound.

Note : The collision test is returning true when there is a collision, so since you objects are in collision you send a "playSound" order and the sound play from the beginning.

   A = getObject("A") 
   B = getObject("B") 
   sound = getObject("sound") 
   collision = 0
   function onSceneUpdate()
       if isCollisionBetween(A, B) then
           if collision == 0 then
               playSound(sound)
           end
           collision = 1
       else
           collision = 0
       end
   end
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox