Parent script calling another parent script

Ask a Question related to Macromedia Director 3D, Design and Development.

  1. #1

    Default Parent script calling another parent script

    For the enemy in my game I let one parent script check if the distance between
    the player and the enemy is low enough. When it is, it calls another parent
    script which should send a bullet in the direction of the player. My problem is
    that the bullet (created entirely within the called parent script) exists for
    only one frame before disappearing. My guess is that the called parent script
    gets deleted for some unknown reason before it can delete itself.
    What should I look out for, anyone experienced the same?

    Here's the code from the calling parent script:
    on aisend me
    if distancebet < 50 then
    me.aishoot()
    end if
    end

    on AIshoot me
    shoottime = shoottime + 1
    if shoottime > 200 then --Can I shoot?
    vAIB = script("AIbullet").new()
    (the actorlist).append(vAIB)
    shoottime = 0
    end if
    end

    And here's the entire AI bullet parent script:

    global KulaRB, w, havok, vecc, kcount, dronetur

    property hke_kulan, kulan
    on new me
    -- Kulan
    kcount = kcount + 15
    kulan = w.newmodel("bullet"&string(kcount), kulaRB)
    put kulan
    kulan.addmodifier(#meshdeform)
    kulaNamnn = "blubb"&string(kcount)

    hke_kulan = havok.makemovablerigidbody(kulan.name, 500, true, #sphere)

    --Kulans shader
    kulan.shader.useDiffuseWithTexture = 1
    kulan.shader.emissive = rgb(0,0,255)
    kulan.shader.diffuse = rgb(0,0,255)
    kulan.shader.blendconstant = 100
    kulan.debug = 1
    --##

    --Send the bullet
    kulan.worldposition = dronetur.worldposition

    havok.registerinterest(hke_kulan.name, #all, 0, 0, #shoot, me)
    havok.registerstepcallback(#shoot, me)
    havok.registerstepcallback(#trajectory, me)
    return me
    end



    on trajectory me
    hke_kulan.applyforce(vecc)
    end

    --End of code

    BTW, "kulan" means "the bullet" in Swedish. I'm too lazy to change it =P


    Mazuho Guest

  2. Similar Questions and Discussions

    1. Referencing (calling) states in the parent component
      Hello All, I think this should be pretty easy to do but I am having a hell of a time doing it. I have a parent component, main.mxml, and a...
    2. Calling a function on the component's parent.
      How would you go about sending an event in the seeting of a popupWindow? I open a popup window child to parent document. I would like to run an...
    3. Contextual Menu Parent Scripts : update and init script available
      Contextual Menu Parent Scripts The code in the Chrome Lib has been fixed and commented. I added an init sample movie script. Two arrow bitmaps...
    4. Parent script - instance help
      Hi I have a movie with several parentscripts. the offspring of these parent scripts have dynamically allocated names. At a certain point, I want to...
    5. #24735 [NEW]: call_user_func on parent method does not use parent private property
      From: tater at potatoe dot com Operating system: OS X 10.2 PHP version: 5CVS-2003-07-21 (dev) PHP Bug Type: Zend Engine 2...
  3. #2

    Default Re: Parent script calling another parent script

    Are you sure the script gets deleted?, how?

    Did you try:

    on stepframe me
    put "i am alive!"
    end stepframe
    ?


    or
    put the actorlist
    --in the message window.
    ?

    hope it works...




    ensamblador Guest

Posting Permissions

  • You may not post new threads
  • You may 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