Gamedev:WeaponMainDir: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
Flozi (talk | contribs)
→Example: forward firing gun: just rewrite that whole block
 
(One intermediate revision by the same user not shown)
Line 7: Line 7:


==Example: forward firing gun==
==Example: forward firing gun==
For instance, if you want your primary weapon to have a 90° fire arc forward, you'd write:
For instance, if you want your primary weapon to have a 90° fire arc forward, you'd write:


{{xtaglink|Gamedev:UnitDefs|weaponMainDir1|[[0 0 1]],}}  -- x:0 y:0 z:1 => that's forward!
<code><pre>weapons = {    
 
  {
{{xtaglink|Gamedev:UnitDefs|maxAngleDif1|90,}}      -- 90° from side to side, or 45° from centre to each direction
    def = "Flamer",
    mainDir = "0 0 1", -- x:0 y:0 z:1 => that's forward!
    maxAngleDif = 90, -- 90° from side to side, or 45° from centre to each direction
  },
}</pre></code>


==Example: two turrets on the sides of a unit==
==Example: two turrets on the sides of a unit==

Latest revision as of 17:02, 24 January 2016

WeaponMainDir

weaponMainDir is a vector showing the direction of the weapon's aiming cone. maxAngleDif is the size of the aiming cone. With these tags you can limit the firing arc of weapons.

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 that Upspring inverts the sign of the x and z axes.

Example: forward firing gun

For instance, if you want your primary weapon to have a 90° fire arc forward, you'd write:

weapons = {		    
  {
    def = "Flamer",
    mainDir = "0 0 1", -- x:0 y:0 z:1 => that's forward!
    maxAngleDif = 90, -- 90° from side to side, or 45° from centre to each direction
  },
}

Example: two turrets on the sides of a unit

This unit that has one turret at left side and one turret at right side.

Each turret can rotate around 220°, a bit more then a semi circle which would be 180° This way each turret can only shot at its side. The firing arcs overlap at front and back so both turrets can fire there.

To achieve this effect, the UnitDef's weapon section looks like this:

weapons = {		    
  {
    def = [[Flamer]],
    mainDir = [[1 0 0]],
    maxAngleDif = 220,
  },
  {
    def = [[Flamer]],
    mainDir = [[-1 0 0]],
    maxAngleDif = 220,
  },
}