Gamedev:WeaponMainDir: Difference between revisions

From Spring
Jump to navigationJump to search
Lurker (talk | contribs)
No edit summary
Flozi (talk | contribs)
→Example: forward firing gun: just rewrite that whole block
 
(9 intermediate revisions by 3 users not shown)
Line 1: Line 1:
==WeaponMainDir: The Simple Way==
= WeaponMainDir =
WeaponMainDirX is a vector showing the direction of the weapon's aiming cone.
{{xtaglink|Gamedev:UnitDefs|weaponMainDir}} is a vector showing the direction of the weapon's aiming cone.
MaxAngleDifX is the size of the aiming cone.
{{xtaglink|Gamedev:UnitDefs|maxAngleDif}} is the size of the aiming cone.
With these tags you can limit the firing arc of weapons.


For instance, if you want your Primary Weapon to have a 90° fire arc forward, you'd write:<br>
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.
  '''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.
==Example: forward firing gun==
For instance, if you want your primary weapon to have a 90° fire arc forward, you'd write: 


<code><pre>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
  },
}</pre></code>


--old confusing explanation removed; if you want it see history--
==Example: two turrets on the sides of a unit==
[[File:Firing_arcs.gif|right]]
This unit that has one turret at left side and one turret at right side.


[[Category:Unit development]]
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 [[Gamedev:UnitDefs|UnitDef's]] weapon section looks like this:
<code><pre>
weapons = {    
  {
    def = [[Flamer]],
    mainDir = [[1 0 0]],
    maxAngleDif = 220,
  },
  {
    def = [[Flamer]],
    mainDir = [[-1 0 0]],
    maxAngleDif = 220,
  },
}
</pre></code>
 
[[Category:Game Dev]]

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,
  },
}