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

  1. #1

    Default Rotating issues

    In a 3dgame I am currently developing I am having a bullet "spawn" from a model
    resource every time the user shoots with his/her tank. Let's say that when the
    game starts the turret is in position A. The user rotates the turret x degrees
    and fires, and the bullet should fly away in the direction the barrel is
    pointing in. My problem now is that the bullet always goes in the same
    direction. It gets spawned from the tip of the barrel just as it should, but if
    I make a 180 degree turn, the bullet flies into the tank instead.

    This is the code for positioning the bullet when it gets spawned:

    bullet = w.newmodel("bullet"&string(pcount), bulletR)
    bullet.worldposition = w.model("turrettarget").worldposition

    --pTurretEnd is a small invicible box at the end of the barrel

    This is the code for the trajectory of the bullet:
    --BulletV = vector(-20,0,0) BulletH = vector(0,0,0.1)
    bullet.transform.translate(BulletV)
    bullet.transform.translate(BulletH)

    Any ideas?

    Mazuho Guest

  2. Similar Questions and Discussions

    1. Rotating Problem
      - I have a a model that rotates by pressing the left- and right arrowkeys. - Now I have a second model that keeps rotating (automatically) until it...
    2. Rotating text
      I used to be able to rotate text as well as the text block using the Selection tool. Now the block rotates, but the text does not. Is there a...
    3. Rotating
      how do I rotate a primitive/model without rotating it's own axis system. example - When creating a cone, it is created with it's sharp end pointing...
    4. Rotating Phrase Box
      I'm trying to make an animation that rotates phrases every five minutes or so. Is a flash animation the way to go? Any suggestions?
    5. Rotating Banner Ads
      How do I set up rotating banner ads? Thanks, Brad ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ www.ropeofsilicon.com
  3. #2

    Default Re: Rotating issues

    Okay, I solved it by doing the following:
    1. Getting a vector from the beginning of the barrel.
    2.Getting a vector from the end of the barrel.
    3. vector c = vector a - vector b
    4. normalized vector c
    5. translated the bullet along the direction vector now aquired (vector c)

    Hope someone finds this useful

    Mazuho 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