Professional Web Applications Themes

Breaking Collision Detection - Macromedia Director 3D

Hi everyone, I was wondering if I could get some help with a problem I'm having. I have a character (which, in the code, is named pCharacter) that needs to collide with an object (named pBall). The problem is, I want the character model to move THROUGH the ball, and detect the collision which occurs. Unfortunately, I can only seem to detect the collision when the objects stop dead at each other. I have pasted the code below. I'd appreciate any help you can offer! Thanks! _________________________________________________ global p3Dmember property pSprite property p3Dmember property pCharacter property pCamera property pCameraz property ...

  1. #1

    Default Breaking Collision Detection

    Hi everyone,

    I was wondering if I could get some help with a problem I'm having. I have a
    character (which, in the code, is named pCharacter) that needs to collide with
    an object (named pBall). The problem is, I want the character model to move
    THROUGH the ball, and detect the collision which occurs. Unfortunately, I can
    only seem to detect the collision when the objects stop dead at each other. I
    have pasted the code below.

    I'd appreciate any help you can offer!

    Thanks!
    _________________________________________________

    global p3Dmember
    property pSprite
    property p3Dmember
    property pCharacter
    property pCamera
    property pCameraz
    property pBall

    on beginSprite me


    p3Dmember = sprite(me.spriteNum).member
    p3Dmember.resetWorld()
    pSprite = sprite(me.spriteNum)

    pCamera = p3Dmember.camera("DefaultView")
    pCameraz = p3Dmember.camera("Cameraview")

    pCharacter = p3Dmember.model("mm_obj:memo")

    pBall = p3Dmember.model("mm_obj:red")

    pCharacter.addChild(pCamera,#preserveParent)
    pCharacter.addChild(pCameraz,#preserveParent)

    theLight = member(2, 1).light("Light")
    theParent = member(2, 1).model("mm_obj:memo")
    theLight.parent = theParent

    createcollisiondetect
    changecamera

    on createCollisionDetect

    p3Dmember.model("mm_obj:collision").addmodifier(#c ollision)
    p3Dmember.model("mm_obj:collision").collision.mode = #mesh
    p3Dmember.model("mm_obj:collision").collision.reso lve = TRUE


    pBall.addmodifier(#collision)
    pBall.collision.mode = #mesh
    pBall.collision.resolve = TRUE


    pCharacter.addmodifier(#collision)
    pCharacter.collision.mode = #mesh
    pCharacter.collision.resolve = TRUE

    pBall.collision.setCollisionCallback(#red, member("colScript"))

    end

    on changeCamera

    if pSprite.camera = p3Dmember.camera("DefaultView") then
    pSprite.camera = p3Dmember.camera("Cameraview")
    else
    pSprite.camera = p3Dmember.camera("DefaultView")
    end if

    end

    on exitFrame me

    if keyPressed(123) then pCharacter.rotate(0,3,0)
    if keyPressed(124) then pCharacter.rotate(0,-3,0)
    if keyPressed(125) then pCharacter.translate(0,0,2)
    if keyPressed(126) then pCharacter.translate(0,0,-2)

    on keyUp
    if the key = "c" then changecamera
    end

    HTiARW Guest

  2. #2

    Default Re: Breaking Collision Detection

    HTiARW wrote:
    >Hi everyone,
    >
    > I was wondering if I could get some help with a problem I'm having. I have a
    >character (which, in the code, is named pCharacter) that needs to collide with
    >an object (named pBall). The problem is, I want the character model to move
    >THROUGH the ball, and detect the collision which occurs. Unfortunately, I can
    >only seem to detect the collision when the objects stop dead at each other. I
    >have pasted the code below.
    >
    > I'd appreciate any help you can offer!
    >
    > Thanks!
    > _________________________________________________
    >
    > global p3Dmember
    > property pSprite
    > property p3Dmember
    > property pCharacter
    > property pCamera
    > property pCameraz
    > property pBall
    >
    > on beginSprite me
    >
    >
    > p3Dmember = sprite(me.spriteNum).member
    > p3Dmember.resetWorld()
    > pSprite = sprite(me.spriteNum)
    >
    > pCamera = p3Dmember.camera("DefaultView")
    > pCameraz = p3Dmember.camera("Cameraview")
    >
    > pCharacter = p3Dmember.model("mm_obj:memo")
    >
    > pBall = p3Dmember.model("mm_obj:red")
    >
    > pCharacter.addChild(pCamera,#preserveParent)
    > pCharacter.addChild(pCameraz,#preserveParent)
    >
    > theLight = member(2, 1).light("Light")
    > theParent = member(2, 1).model("mm_obj:memo")
    > theLight.parent = theParent
    >
    > createcollisiondetect
    > changecamera
    >
    > on createCollisionDetect
    >
    > p3Dmember.model("mm_obj:collision").addmodifier(#c ollision)
    > p3Dmember.model("mm_obj:collision").collision.mode = #mesh
    > p3Dmember.model("mm_obj:collision").collision.reso lve = TRUE
    >
    >
    > pBall.addmodifier(#collision)
    > pBall.collision.mode = #mesh
    > pBall.collision.resolve = TRUE
    >
    >
    > pCharacter.addmodifier(#collision)
    > pCharacter.collision.mode = #mesh
    > pCharacter.collision.resolve = TRUE
    >
    > pBall.collision.setCollisionCallback(#red, member("colScript"))
    >
    > end
    >
    > on changeCamera
    >
    > if pSprite.camera = p3Dmember.camera("DefaultView") then
    > pSprite.camera = p3Dmember.camera("Cameraview")
    > else
    > pSprite.camera = p3Dmember.camera("DefaultView")
    > end if
    >
    > end
    >
    > on exitFrame me
    >
    > if keyPressed(123) then pCharacter.rotate(0,3,0)
    > if keyPressed(124) then pCharacter.rotate(0,-3,0)
    > if keyPressed(125) then pCharacter.translate(0,0,2)
    > if keyPressed(126) then pCharacter.translate(0,0,-2)
    >
    > on keyUp
    > if the key = "c" then changecamera
    > end
    >
    >
    >
    Take a look to 'modelsUnderRay' to detect the distance between two
    models...

    --
    ----------------------------------
    Diego Mangoni
    Multimedia Developer
    [url]http://www.dmzone.it[/url]
    ----------------------------------
    Diego Guest

  3. #3

    Default Re: Breaking Collision Detection

    Thanks!

    I've tried modelsunderray, but it takes up too much processing power! Is there any other way to detect the intersection of 3D models?
    HTiARW Guest

Similar Threads

  1. collision detection
    By Seph webforumsuser@macromedia.com in forum Macromedia Director 3D
    Replies: 18
    Last Post: May 20th, 09:24 AM
  2. Collision Detection - what am I missing.
    By Mick the Brick in forum Macromedia Director 3D
    Replies: 2
    Last Post: February 8th, 01:06 PM
  3. Collision detection problems
    By tacbob in forum Macromedia Director 3D
    Replies: 5
    Last Post: November 24th, 02:44 PM
  4. 3d collision detection
    By needhelp2005 in forum Macromedia Director 3D
    Replies: 0
    Last Post: May 9th, 10:33 PM
  5. Massive collision detection
    By oeyvind toft in forum Macromedia Flash
    Replies: 6
    Last Post: August 5th, 02:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139