1 Reply Latest reply on Feb 8, 2007 8:44 AM by mpwalker

    modified gravity function

    mpwalker
      Hello,
      I'm working on a pseudo 3d game, a plane/helicopter shooting game, that uses Jared Hope's re-animator camera to simulate being inside the cockpit. My problem is, I'm trying to create enemy "ai" (really just a simple gravity function that's not too processor intensive and based around a moving point--the camera) that will pull the enemy MC's towards the center of the camera MC where they will fire at you. If you'd like you can download the file as it is right now.

      Heres the little bit of code I was able to come up with as a test of concept.

      //Code on the enemy MC
      onClipEvent (enterFrame) {
      if (this._x >= _root.cockpit._x) {
      xdirect = -_root.enemySpeedx;
      } else {
      xdirect = _root.enemySpeedx;
      }
      if (this._y > _root.cockpit._y) {
      ydirect = -_root.enemySpeedy;
      }else{
      ydirect = _root.enemySpeedy;
      }
      this._x += xdirect;
      this._y += ydirect;
      }

      This does not work well at all--extremely glitchy and seems to slow the movie considerably. If anyone can lend a hand to an inexperienced programmer it would sure be appreciated.