Set Acceleration
A set acceleration node adds a long-lasting acceleration to an object.
Acceleration on Objects[edit | edit source]
LuaSTG has built-in support for the implementation of acceleration ("force") on objects. This is done by the introduction of .ax and .ay attributes on each LuaSTG object. On each frame, the engine automatically adds the values of .ax and .ay to the velocity .vx and .vy respectively.
A set acceleration node will take advantage of this feature, and simply sets the values of .ax and .ay of an object to values calculated from Acceleration and Angle parameters.
As you may have noticed, this algorithm is an approximation. This is something to keep in mind if you want to write code for something like a pattern that involves gravity bullets rebound on four sides of the screen, as the error could add up quickly.
Parameters[edit | edit source]
Here is a list of parameters of a set acceleration node.
Parameters | Function |
---|---|
Target | (LuaSTG object) the object to set acceleration on |
Acceleration | (number) The magnitude of acceleration. The unit is in LuaSTG distance unit per frame squared |
Angle | (number) The direction of acceleration. The unit is in degrees |
Aim to Player | (boolean) If set to true, an offset value Angle(self, player) will be added to the Angle of acceleration |