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 materials, they can not be applied to the box or pyramid objects unless the server (BZFS) is version 2.0.9 or later.
The valid parameters for physics are:
- Name of the physics driver, for reference
- 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).
- Cause a tank to rotate at the given velocity,(Rotation velocity, x/y coordinates of the centre).
- Cause the tank to accelerate slowly during the time given. (i.e. Makes a 'slippery' surface.)(Time until max velocity (> 0.0 enables)
- Causes the tank to die on contact. Player sees the given message
Working with Physics
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
Physics is supported by the BZWTools for Blender.
The Physics object was added with the v2.0.0 release of BZFlag.