Gamedev:WeaponMainDir

From Spring
Revision as of 03:09, 4 July 2007 by ErkVle (talk | contribs)
Jump to navigationJump to search

diazepam online cheap tramadol wellbutrin online jazz ringtones rivotril online mtv ringtones cheap lipitor cheap celexa ativan online nokia ringtones norco online free motorola ringtones ultram ultram online norco mono ringtones celexa online buy didrex online pharmacy cheap propecia cheap phentermine buy viagra vicodin online cheap sildenafil cheap lisinopril free sharp ringtones levitra free funny ringtones but hydrocodone valium online free cool ringtones clonazepam online cyclobenzaprine online verizon ringtones hgh online ambien online free sony ringtones cialis online free cingular ringtones cialis online prozac online qwest ringtones didrex online free punk ringtones free jazz ringtones free ringtones ultracet order flexeril free nokia ringtones cheap ativan viagra online midi ringtones free sony ericsson ringtones free real ringtones cheap adipex funny ringtones punk ringtones cheap tenuate meridia free kyocera ringtones free sprint ringtones meridia online order tenuate clomid online ambien online sonyericsson ringtones cheap clomid music ringtones free ericsson ringtones cheap levitra wwe ringtones free kyocera ringtones cheap nexium free mp3 ringtones hgh online cheap xanax free sagem ringtones cheap xenical alprazolam free music ringtones buy zanaflex verizon ringtones free nextel ringtones tracfone ringtones diethylpropion online cheap albuterol buy tramadol samsung ringtones free mp3 ringtones free wwe ringtones soma online sharp ringtones lisinopril online cheap paxil free motorola ringtones free samsung ringtones vigrx cheap sildenafil paxil online cheap zanaflex cheap rivotril diethylpropion online sprint ringtones free polyphonic ringtones free sagem ringtones cheap nexium free cingular ringtones cheap cyclobenzaprine pharmacy online online alltel ringtones sonyericsson ringtones sony ericsson ringtones diazepam online online vicodin buy lipitor cheap vigrx mtv ringtones soma online lorazepam online free real ringtones zyban online buy albuterol free ericsson ringtones lorazepam online cheap zoloft but adipex buy wellbutrin free alltel ringtones free cool ringtones free nextel ringtones zoloft online clonazepam online valium online cheap fioricet free midi ringtones xanax online free polyphonic ringtones hoodia online cheap lortab order alprazolam hydrocodone online cheap lortab cheap ultracet free free ringtones free mono ringtones carisoprodol online sony ringtones cheap ortho tracfone ringtones but phentermine cheap ortho xenical online prozac online carisoprodol online propecia online but flexeril free qwest ringtones buy fioricet hoodia online zyban online ==WeaponMainDir: The Simple Way== WeaponMainDirX is the coordinate of the vector showing the axis of the cone.

For instance, if you want your Primary Weapon to have a 90° fire arc forward, you'd write:
WeaponMainDir1=0 0 1;//x:0 y:0 z:1 => that's forward!
MaxAngleDif1=90;//90° from side to side, or 45° from center to each direction

If you want to precisely choose the WeaponMainDir, you could run UpSpring, create a new piece, move it around until the line, from the origin, to your piece, is along the line you want your weapon to fire, then write down the coordinate in WeaponMainDir. Keep in mind UpSpring invert the sign of the axis x and z.

No idea why people came up with the confusing explanation below, but I'll leave it anyway just in case.

WeaponMainDir: The lowdown

After so many months, I finally figured out how to get the angles I want in WeaponMainDir! It defines the position of a point that the engine gets the vector of from the weapon origin, like so: o---->o First o is the weapon origin, defined in the query function of your script. The second is defined by the coordinates of WeaponMainDir. So, to figure out your numbers (still using o's as the two points): Draw a triangle DistanceX OR DistanceY

o _____________
  \            |
    \          |
      \        |
        \      | DistanceZ
          \    |
            \  | <--- This is your desired angle. 
              \| 
               o <--- Weapon origin

Ignore the DistanceY for now.

Lets say you want your gun to aim in a forward facing, 12 degree cone. Well, the degrees in MaxAngleDif start at the vector, and go around clockwise (for X/Z, not certain about Y/Z, but I think it is counter-clockwise) from there, so the default value of straight forward, 0 0 1, will aim straight forward and 12 degrees to the unit's right). Looking like so: (0 to 12 degrees) __ |/ You need to have that vector be 6 degrees to the left so the cone is actually centered on 0: (-6 to 6 degrees) __ \|/

Now, if you're comfortable with trigonometry, you can look at the big diagram above and see that the distance you need is opposite the angle/ adjacent the angle = TAN(of the angle). Pull out your handy dandy scientific calculator (or change the one in windows to scientific mode) and plug in TAN(6), getting 0.105104.... Now start trying out fractions of X/Z using the "guess then narrow it down" method (thats the first number and last number of the three defined in MaxAngleDif), to try to get them close (3rd or 4th decimal place should be close enough accuracy) to that decimal number. They have to be whole numbers! (Why? Because I'm not testing it) If your a trig wizz, which I am not, you may have picked the best numbers just by looking at it. You should find 2/19 produces a good value of 0.105264... Check your values by doing arctan(X/Z) (may be tan(superscript)-1 on your calculator, not to be confused with 1/tan, so don't try that if you can't find it). This should give a number very close to your angle, if you went to the 3rd decimal place in accuracy when picking your X/Z, then the value will be about that accurate as well. In our case, arctan(2/19)=6.009006...

Booya!

If you want that 12 degree cone to be centered around 90 degrees left of the unit, you'd take your 6 degree angle, and add it to 90, so you'd do the process on 96 degrees. You'll find tan(96) comes out negative, thats because your Z value is going to be negative. Go ahead and graph it on a piece of paper if you don't see why its negative.

Now, that DistanceY I told you to ignore! Lets look at it now. You work it the same as for DistanceX. Lets just say when working out your numbers for X you were looking top-down at your unit, for Y your looking at the side. If your using X/Z already, you'll have to use that same Z value in your Y/Z. Well, at least it makes figuring out Y easier, just multiply the value from tan(angle) by Z. Problem is it will probably be a decimal that you can't round without it being horribly inaccurate. If it is (which is very likely), you might try finding your Y/Z values as when you found X/Z, then use "Least Common Denominators" to have equal Z values and still the desired accuracy on X and Y.