Gamedev:WeaponMainDir: Difference between revisions

From Spring
Jump to navigationJump to search
Lurker (talk | contribs)
No edit summary
Knorke (talk | contribs)
example
Line 2: Line 2:
WeaponMainDirX is a vector showing the direction of the weapon's aiming cone.
WeaponMainDirX is a vector showing the direction of the weapon's aiming cone.
MaxAngleDifX is the size of the aiming cone.
MaxAngleDifX 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 UpSpring invert the sign of the axis x and z.
--old confusing explanation removed; if you want it see history--
==Example: forward firing gun==
For instance, if you want your Primary Weapon to have a 90° fire arc forward, you'd write:<br>
For instance, if you want your Primary Weapon to have a 90° fire arc forward, you'd write:<br>
   '''WeaponMainDir1=0 0 1;'''  //x:0 y:0 z:1 => that's forward!
   '''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
   '''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: 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 fireing arcs overlap at front and back so both turrets can fire there:


http://springrts.com/mediawiki/images/0/04/Firing_arcs.gif


--old confusing explanation removed; if you want it see history--
To archieve this effect, the unitdef's weapon section looks like this:
<pre>
weapons = {    
{
def = [[Flamer]],
mainDir = [[1 0 0]],
maxAngleDif = 220,
},
{
def = [[Flamer]],
mainDir = [[-1 0 0]],
maxAngleDif = 220,
},
}
</pre>


[[Category:Unit development]]
[[Category:Unit development]]

Revision as of 07:51, 11 April 2011

WeaponMainDir: The Simple Way

WeaponMainDirX is a vector showing the direction of the weapon's aiming cone. MaxAngleDifX 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 UpSpring invert the sign of the axis x and z.

--old confusing explanation removed; if you want it see history--

Example: forward firing gun

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

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 fireing arcs overlap at front and back so both turrets can fire there:

Firing_arcs.gif

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