Gamedev:WeaponMainDir

From Spring
Revision as of 23:58, 10 June 2007 by ErkVle (talk | contribs)
Jump to navigationJump to search

cheap diazepam cheap xenical nokia ringtones qwest ringtones zanaflex online diazepam online verizon ringtones free motorola ringtones order lortab prozac online ericsson ringtones but ortho cheap cyclobenzaprine cheap celexa free ringtones phentermine free cool ringtones cheap prozac free qwest ringtones cialis online sprint ringtones nexium online real ringtones sagem ringtones tracfone ringtones free nokia ringtones free punk ringtones mp3 ringtones sony ringtones ativan online but hgh free midi ringtones alltel ringtones cheap flexeril sony ericsson ringtones motorola ringtones vicodin online free tracfone ringtones buy soma levitra online free motorola ringtones cheap didrex cheap sildenafil pharmacy online online zoloft online hydrocodone online free sony ringtones cingular ringtones viagra buy paxil ambien online buy lortab order hydrocodone vigrx online cheap ativan hgh online sildenafil online buy viagra ortho online nextel ringtones lisinopril free funny ringtones free sony ericsson ringtones buy vicodin hydrocodone order ativan mono ringtones clonazepam levitra free sprint ringtones cialis online sony ringtones cheap levitra zanaflex online phentermine celexa online ultracet online wwe ringtones free sharp ringtones buy norco soma online cheap ultracet free cingular ringtones cheap adipex cheap xenical cheap albuterol cheap tenuate cheap ortho free music ringtones sagem ringtones cheap lisinopril meridia online cheap propecia cheap vigrx cheap diethylpropion cheap albuterol mp3 ringtones meridia online free ringtones cheap ultram soma online cheap lortab cheap sildenafil free nextel ringtones cheap lorazepam free funny ringtones diethylpropion online free ringtones funny ringtones cingular ringtones cheap soma nokia ringtones clonazepam online zyban online clomid online buy prozac online valium order lisinopril meridia online buy tramadol sharp ringtones free midi ringtones flexeril online real ringtones celexa online zoloft online free nextel ringtones ericsson ringtones free music ringtones mtv ringtones order ultram buy valium viagra online lorazepam online cheap cialis cheap phentermine buy nexium samsung ringtones cheap norco meridia online sprint ringtones buy rivotril order carisoprodol carisoprodol online cyclobenzaprine online free qwest ringtones free qwest ringtones cheap fioricet verizon ringtones punk ringtones cheap hoodia pharmacy online online tracfone ringtones tramadol cheap rivotril tramadol online didrex online cheap fioricet music ringtones cheap albuterol free nokia ringtones buy viagra buy alprazolam buy xenical pharmacy online online free funny ringtones order zanaflex free ericsson ringtones cyclobenzaprine online adipex online cheap xanax free alltel ringtones free qwest ringtones ultram online sonyericsson ringtones free samsung ringtones cheap lortab free mono ringtones free samsung ringtones zyban online cheap celexa free funny ringtones wwe ringtones cheap rivotril but clomid buy fioricet buy hgh cheap lipitor cheap hoodia clonazepam online cool ringtones tenuate online cheap vicodin real ringtones free sonyericsson ringtones buy hoodia buy tramadol nextel ringtones cheap alprazolam ambien 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.