Editing Physics

Jump to: navigation, search

Warning: The database has been locked for maintenance, so you will not be able to save your edits right now. You may wish to copy and paste your text into a text file and save it for later.

The administrator who locked it offered this explanation: Server migration

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
Physics, or Physics Driver, when applied to an object, will affect a tank touching it in some way.  Physics can be applied to any 2.0 object, namely: [[mesh]], [[meshbox]],[[meshpyr]],[[sphere]],[[cone]],[[tetra]], and [[arc]]. Similar to [[material|materials]], they can not be applied to the [[box]] or [[pyramid]] objects unless the server ([[BZFS]]) is version 2.0.9 or later.
+
Physics, or Physics Driver, can be applied to any 2.0 object, for example a [[mesh]] or [[meshbox]]. It will affect a tank touching it in some way.
  
 +
== Code ==
 +
{|
 +
|
 +
physics
 +
  name example_phydrv
 +
  linear 0.0 0.0 0.0
 +
  angular 0.0 0.0 0.0
 +
  slide 0.0
 +
  death Message goes here.
 +
end
 +
|}
 
The valid parameters for physics are:
 
The valid parameters for physics are:
{|{{Prettytable}}
+
<properties>
|-
+
name=Name of the physics driver, for reference
| {{Hl3}} |'''Parameter'''
+
linear=Cause a tank to move linearly at the given velocity (x/y/z). For example linear 5 0 0 would cause any tanks on the object to move at a velocity of 5 towards X+ (the side of the map with the highest value of X).
| {{Hl3}} |'''Description'''
+
angular=Cause a tank to rotate at the given velocity,(Rotation velocity, x/y coordinates of the centre).
|-
+
slide=Cause the tank to accelerate slowly during the time given. (i.e. Makes a 'slippery' surface.)(Time until max velocity (> 0.0 enables)
| name || Name of the physics driver, for reference.                                                                           
+
death=Causes the tank to die on contact. Player sees the given message
|-
+
</properties>
| linear || Cause a tank to move linearly at the given velocity (x/y/z). For example linear 5 0 0 would cause any tanks on the object to move at a velocity of 5 towards X+ (the side of the map with the highest value of X).                    
+
|-
+
| angular || Cause a tank to rotate at the given velocity,(Rotation velocity, x/y coordinates of the centre).
+
|-
+
| slide || Cause the tank to accelerate slowly during the time given. (i.e. Makes a 'slippery' surface.)(Time until max velocity (> 0.0 enables).                   
+
|-
+
| death || Causes the tank to die on contact. Player sees the given message
+
|}
+
  
== Working with Physics ==
+
A physics driver can be called by adding 'phydrv <name>' to an object, group or mesh face. '''Physics drivers do not work on boxes and pyramids in version 2.0.8'''
 
+
Physics drivers are applied to objects to affect tanks. Physics can be applied to all BZW world objects, including individual mesh faces.
+
From bzw man page:
+
 
+
physics
+
  name example_phydrv
+
  linear  0.0 0.0 0.0  # x/y/z linear velocities
+
  angular 0.0 0.0 0.0  # rotation freq, x/y coordinates
+
  slide 0.0            # time until max velocity  (> 0.0 enables)
+
  death Message goes here. # the 'death' property requires a non-blank message
+
end
+
 
+
 
+
Death - Kills the tank and gives specific message. Example:
+
 
+
physics
+
  name landmine
+
  death Oops!You hit a landmine!
+
end
+
meshbox
+
  position 0 0 0
+
  size 10 10 5
+
  phydrv landmine
+
end
+
 
+
 
+
Slide - Reduces the friction of surface. Value specified determines time to reach full speed. If you set value of 1, it takes one second to reach maximum speed on surface. Slide feels like slippery ice and makes accurate shooting difficult.
+
 
+
physics
+
  name slippery
+
  slide 0.5
+
end
+
meshbox
+
  position 0 0 0
+
  size 10 10 5
+
  phydrv slippery
+
end
+
 
+
 
+
Avenue - Linear and angular make the tank move. Linear motion can be used to make escalators, trampolines etc. Values given are motion in x/y/z. Usually, you want Z to be zero, so that it won't throw tank into air. Note that physics driver does not imply moving texture. This example makes a physics driver, moving 10 units per second in x-axis direction, and applies it to meshbox 200 units long in x direction.
+
 
+
# Simple box with horizontal physics driver:
+
physics
+
  name moving
+
  linear 10 0 0
+
end
+
meshbox
+
  position 0 0 0
+
  size 200 10 5
+
  phydrv moving
+
end
+
 
+
 
+
Trampoline - Setting Z axis motion to higher value than zero makes a trampoline.
+
Value defines the initial vertical velocity tank gets.Note that it is relational to the height of the trampoline. You can calculate how high tank goes as follows:
+
Height = ( velocity ^ 2 ) / ( 2 * gravity )
+
Default gravity is 9.81, so in our example:
+
Height = ( 50 ^ 2 ) / ( 2 * 9.81 ) = 2500 / 19.62 = ~ 127 units
+
However, the equations of physics can only be used as estimates, and are usually not accurate to one decimal point. This is because bzflag does not attempt replicate all aspects of real world physics, as can be easily observed.
+
 
+
# Trampoline
+
physics
+
  name trampoline
+
  linear 0 0 50
+
end
+
meshbox
+
  position 0 0 0
+
  size 10 10 5
+
  phydrv trampoline
+
end
+
 
+
 
+
Angular movement - First of three values after angular-keyword tells the rotation speed per second. Second and third are the x/y position of center point. To get actual movement speed, use:
+
Speed = Rotation * 2 * Distance from center * PI
+
Pi is approximately 3.14159, and the speed on the outer edge of our example is:
+
Speed = 0.1 * 2 * 50 * 3.14159 = ~ 31 units per second
+
 
+
physics
+
  name spin
+
  angular 0.1 0 0
+
end
+
arc
+
  position 0 0 0
+
  size 50 50 5
+
  phydrv spin
+
end
+
 
+
Escalators are a special type of linear motion. When using physics drivers, you must note that object rotation or spin don't affect them. If you want mirrored escalators, you must have two physic drivers. Escalators need both vertical and horizontal movement, and you must experiement a bit to have suitable values. You might need to move backwards a bit on the escalator to get up - this depends on how well the movement values fit together. To have nice looking escalators you should use shear (described in 3d transformations) so that the ends don't "stick" out of ground. Spin or mesh won't be described here.
+
 
+
physics
+
  name escalator
+
  linear 10 0 10
+
end
+
meshbox
+
  size 100 10 5
+
  spin -45 0 1 0 #spin -45 degrees around y-axis
+
  shift 0 0 71 #shift is like position, but works better with spin.
+
  phydrv escalator
+
end
+
  
 
== Editor Support ==
 
== Editor Support ==
Physics is supported by the BZWTools for Blender.
+
There are currently no supported editors: physics drivers will need to be added by hand in a text editor.
  
 
==History==
 
==History==

Please note that all contributions to BZFlagWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see BZFlagWiki:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)

Templates used on this page: