4 Replies Latest reply on Apr 5, 2008 5:49 AM by rlc5611

    Missile not working

      ok. I am quite new to actionscript (about 2 weeks to be more precise) and i am trying to make my missile shoot out of my fighter (that works) and then travel in the direction it is facing (if it doesnt explode immediately it also works) and after a certain amount of time it should explode. The problem is that the missile explodes as soon as its created. Ill provide myg WIP to see if it helps (i wouldnt be able to describe very well

      Link here

      Oh and if it makes any difference im using actionscript 2.0
        • 1. Re: Missile not working
          rlc5611 Level 1
          For one thing if you look inside your missile_1 clip and look on the first frame of the actionscript, you have:

          if ((detonation_timer=15))

          but should be

          if ((detonation_timer==15))

          I see you have a similar error in the

          if ( (this._name<>"missile_1")and(missile_explosion_on=1) ) {

          should be again "==" instead of "="

          But I also don't see that your missile ever moves and that is because you don't have the conditional set up in a loop like an onEnterFrame event. You only check once. I think you have other problems as well but your AS is spread out all over the place and it is confusing to follow.
          • 2. Re: Missile not working
            rlc5611 Level 1
            I can also see a potential conflict in your logic and the use of what are essentially global variables. There is nothing to prevent creation of multiple missile clips and they are all using the same variable within the scope of the _root. I think you should make your variables that you are using in your onEnterFrame and onLoad events local to the newly created clips.

            One more "problem" I see is that after your missile's detonation_timer reaches a certain value, you go to the explosion frame and play the explosion until the clip is removed. The issue is that your onEnterFrame function is continuing to run throughout the explosion until the clip is eventually removed. Your logic should be such that, once you decide you want an explosion, you remove the onEnterFrame event.
            • 3. Re: Missile not working
              rlc5611 Level 1
              It would be better if you placed all your AS in the main timeline. As a test, click on your enemy and delete all the AS you have on that clip. Click on the main fighter and delete all the AS you have on that clip. Open up your missle and delete all the AS in that clip except the stop() in the first frame. Delete the missle_explosion as you never use it.

              name your crosshair movie clip with the instance name "crosshair".

              Now in the main timeline in the "stopper" layer, click on the keyframe where you have the stop() and add the attached.

              This will take care of your fighters, missles and explosions and keep everything correctly ordered. It will also be much easier to maintain and update your script this way.
              • 4. Re: Missile not working
                rlc5611 Level 1
                I was playing with your missle hitTest mainly because I just can't get over seeing a jet go backwards. The enemy jet has a very large footprint so it is very easy for the missle to blow up close to the enemy even if it hasn't actually hit the enemy. Maybe it has a proximity trigger. I dunno.

                So I outlined your enemy jet movie clip with 26 child clips named h1 through h26 and did the hitTest on each of those rather than the larger enemy. That code is attached.