PHY_InitObject(objectid, modelid = 0, Float:mass = 1.0, Float:size = FLOAT_NAN, mode = PHY_MODE_3D)
/*Starts using physics for objectid.
modelid - object's modelid, used to get its size with modelsizes include.
mass - object's mass, it is like its weight and is used in collisions.
size - object's sphere radius, taken from modelsizes.inc by default.
mode - PHY_MODE_3D or PHY_MODE_2D.*/
PHY_GetObjectMode(objectid)
PHY_DeleteObject(objectid)
/*Stops using physics for objectid (doesn't destroy it).*/
PHY_SetObjectVelocity(objectid, Float:vx, Float:vy, Float:vz = 0.0)
/*Moves the object with vx, vy, vz velocities.*/
PHY_GetObjectVelocity(objectid, &Float:vx, &Float:vy, &Float:vz)
PHY_IsObjectMoving(objectid)
PHY_SetObjectAcceleration(objectid, Float:ax, Float:ay, Float:az = 0.0)
/*Sets the object's acceleration.*/
PHY_GetObjectAcceleration(objectid, &Float:ax, &Float:ay, &Float:az)
PHY_GetObjectSpeed(objectid, &Float:speed, _3D = 0)
PHY_GetObjectMoveAngle(objectid, &Float:moveangle)
stock PHY_RollObject(objectid, toggle = 1, rollingmode = PHY_ROLLING_MODE_DEFAULT)
/* Starts rolling the object when it moves of toggle = 1 or stops if toggle = 0.
rollingmode = PHY_ROLLING_MODE_DEFAULT (Euler angles) or PHY_ROLLING_MODE_ADVANCED (Quaternions)
When using advanced rolling mode, if you manually use SetObjectRot in your script, it is adviced to
call PHY_RollObject again, in order to recalculate its quaternion angles.*/
PHY_IsObjectRolling(objectid)
PHY_SetObjectFriction(objectid, Float:friction)
/*Applies friction to the object when it moves on the floor (at its lowest Z). If friction is applied, the object gradually slows down.*/
Float:PHY_GetObjectFriction(objectid)
PHY_SetObjectAirResistance(objectid, Float:resistance)
/*Applies air resistance to the object when it moves. The difference between friction and air resistance is that the former works only if the object is on the floor and the letter is also slows down the object proportionally to its velocity.*/
Float:PHY_GetObjectAirResistance(objectid)
PHY_SetObjectZBound(objectid, Float:low = FLOAT_NAN, Float:high = FLOAT_NAN, Float:constant = 0.0)
/*Limits the object's Z position.
low - The lowest Z that the object can have (you can use FLOAT_NEG_INFINITY). If it is set to NaN it doesn't change.
high - The highest Z that the object can have (you can use FLOAT_INFINITY). If it is set to NaN it doesn't change.
(When you use PHY_InitObject lowest Z is set to the current object's Z and highest Z to FLOAT_INFINITY.
constant - It should be from 0.0 to 1.0. If it is 1.0 the object doesn't lose velocity,
if it is 0.0 the object stops when it bounces. It could be a middle ground.*/
PHY_SetObjectGravity(objectid, Float:gravity)
/*Sets the gravity's acceleration that the object is subjected to.*/
Float:PHY_GetObjectGravity(objectid)
PHY_SetObjectWorld(objectid, world)
/*Object and walls collide only if the are in the same world or one of them is in the world 0 (default).*/
PHY_ToggleObjectPlayerColls(objectid, toggle = 1, Float:constant = 1.0, Float:distoffset = 0.8, Float:zoffsetlow = 1.0, Float:zoffsethigh = 1.0)
/*Toggles object's collisions with players.
- constant - It should be from 0.0 to 1.0. If it is 1.0 the object doesn't lose velocity,
if it is 0.0 the object stops when it bounces. It could be a middle ground.
- distoffset - The distance at which the object collides with the player.
- zoffsetlow/zoffsethigh - The max Z distance (downward/upward) at which the object collides with the player.*/
PHY_ApplyRotation(objectid, Float:speed, Float:moveangle)
/*Function used internally to rotate the objects.*/
PHY_CreateWall(Float:x1, Float:y1, Float:x2, Float:y2, Float:constant = 1.0, Float:low = FLOAT_NEG_INFINITY, Float:high = FLOAT_INFINITY)
/*Creates a collision wall (straight line) from A(x1, y1) to B(x2, y2).
constant should be from 0.0 to 1.0. If it is 1.0 the object doesn't lose velocity,
if it is 0.0 the object stops when it collides.
low is the lowest wall's Z, high is the highest. If they're set to default the wall is like infinitely high. */
PHY_CreateArea(Float:minX, Float:minY, Float:maxX, Float:maxY, Float:constant = 1.0, Float:low = FLOAT_NEG_INFINITY, Float:high = FLOAT_INFINITY)
/*Creates four walls that form an area. Works like IsPlayerInArea.*/
PHY_DestroyWall(wallid)
PHY_SetWallWorld(wallid, world)
PHY_CreateCylinder(Float:x, Float:y, Float:size, Float:constant = 1.0, Float:low = FLOAT_NEG_INFINITY, Float:high = FLOAT_INFINITY)
/*Creates a collision cylinder at position x, y.
constant should be from 0.0 to 1.0. If it is 1.0 the object doesn't lose velocity,
if it is 0.0 the object stops when it collides.
low is the lowest cylinder's Z, high is the highest. If they're set to default the cylinder is like infinitely high.*/
PHY_DestroyCylinder(cylinderid)
PHY_SetCylinderWorld(cylinderid, world)
PHY_SetPlayerWorld(playerid, world)
PHY_UseColAndreas(objectid, mode = 1)
/* Sets ColAndreas mode for the object. Modes: 0 none, 1 collisions + z bounds, 2 collisions only, 3 z bounds only */
/* Callbacks */
forward PHY_OnObjectUpdate(objectid);
forward PHY_OnObjectCollideWithObject(object1, object2);
forward PHY_OnObjectCollideWithZBound(objectid, lowhigh); // low bound = 0, high bound = 1
forward PHY_OnObjectCollideWithSAWorld(objectid, Float:cx, Float:cy, Float:cz); // Only with ColAndreas
forward PHY_OnObjectCollideWithWall(objectid, wallid);
forward PHY_OnObjectCollideWithCylinder(objectid, cylinderid);
forward PHY_OnObjectCollideWithPlayer(objectid, playerid);
Wonderful!
I noticed a small bug. In your movie, at 0:31 in the left part of the screen there is a ball colliding with a stationary ball and the second ball starts rotating awkwardly. EDIT: It looks like there are more balls that are not moving, but rotating. Sugestion: Make objects collide with players and vehicles. |