Physics

From HIVE
Jump to navigation Jump to search

Physics refers to the collection of observed laws of nature, such as gravity and inertia. It may also refer to the replication of such laws in a video game.

Physics adds to the realism of a StarCraft II map. It furthers in-game objects' interactions with the environment. Adding gravity to a map, for example, allows objects to fall off of cliffs, and slows objects' movements as they travel up a slope.

Details

To properly recreate real-life physics in StarCraft II, you'll need certain pieces of information and proper formulas. For example, to slow down or speed up a unit depending on the hill they're on, you'll need to calculate the slope of the hill that the unit is currently on, and use that information to speed up or slow down the unit. The easiest way is to set the speed to its current speed and subtract the slope times a constant - the constant will depend on how often the trigger is being run. Note that while this isn't a real-life physics technique, it's an effective method for simulating it on StarCraft II.

When working with physics and terrain, one of the things you'll often find yourself wanting to do is to stop a unit from moving up a hill of sufficient steepness. At high speeds, due to the nature of movement as being horizontal (Basically, when it says that a unit moves at a speed of four, it means it moves at four horizontally. If you create a very steep cliff and send a unit up it, it'll get to the top almost instantly), the slowdown from the slope will be insufficient, so you might find yourself needing a more abrupt method. One solution is to detect when the slope is above a certain value and stop it. One problem with this might be that the unit is now stuck halfway up a cliff, so, assuming you use technique one of Slope, you move it back to a previous location it was at.

When working in 3D and simulating jumps and flight, there are several additional concepts that you might need to be aware of. The first is that you can calculate total height of a unit using "Height of Unit" to detect distance from ground to the unit (if it's a flying unit) and "Height at point" to detect the height of the terrain from 0 at that point. This total number is the number you should work on to effectively simulating physics, as either one of those functions alone will vary with the terrain and be unworkable. Additionally, if you're attempting to make a ground unit fly, you can base an ability off the Viking's "Transform" to create an alternate flying version of the unit, or you can attempt to made something happen using the Reaper's "Jump".