Repository navigation
A3D_CreateObject
Create a moving physics object shaped like the collision of a model, or as models.json describes the model.
A model in models.json takes the shape, friction, bounce, damping, rolling friction, buoyancy and sync error the file gives it, and its mass when mass is 0.0. What the file leaves out comes from the model: the mass from the volume of its shape and the density of what most of its collision is made of, the friction and bounce from that material.
native Physic:A3D_CreateObject(
modelid,
Float:x,
Float:y,
Float:z,
Float:rx = 0.0,
Float:ry = 0.0,
Float:rz = 0.0,
Float:mass = 0.0,
worldid = -1
);| Parameter | Description | Default |
|---|---|---|
modelid |
Model shown, and whose collision gives the shape. | |
Float:x |
Position on the X axis. | |
Float:y |
Position on the Y axis. | |
Float:z |
Position on the Z axis. | |
Float:rx |
Rotation on the X axis. | 0.0 |
Float:ry |
Rotation on the Y axis. | 0.0 |
Float:rz |
Rotation on the Z axis. | 0.0 |
Float:mass |
Mass in kilograms, or 0.0 for the mass in models.json, or else the one the model gives from its volume. |
0.0 |
worldid |
Virtual world it collides in, or -1 for every world. |
-1 |
- The physics object.
-
INVALID_PHYSIC_IDwhen the model has no collision and no shape inmodels.json, or the world is full.
A model listed in models.json moves with the sphere, box, cylinder or collision the file gives it, and starts with its friction, bounce, damping, rolling friction, buoyancy and sync error. Its mass is the one of the file when mass is 0.0, the default, and a mass passed by the script wins.
A model the file leaves out, and each mass, friction and bounce an entry leaves out, is estimated from the model: the mass from the volume of its shape and the density of what its collision is made of, the friction and bounce from that material. A crate weighs some kilograms and a dumpster some hundreds without a line in the file.
A model the file gives no shape moves with the convex hull of its collision, or with its only sphere or box when the collision holds just one. A hollow model, such as a bin or a crate with an open top, moves as a solid block. Something that never moves keeps its exact collision with A3D_CreateStaticObject.
The model must then have collision in the map database. It holds every model of the game and the models SA-MP adds, but some models have no collision, such as balls and weapons, and the models a server adds with AddSimpleModel are not in it. Those give INVALID_PHYSIC_ID unless models.json gives them a shape.
The component creates a global object of the same model and moves it with the body. A global object shows in every virtual world. To show the object in one world only, create the body with -1 as the model and hand a streamer object to A3D_AttachDynamicObject.
A new object is awake and falls at once. Unless models.json or the material of the model says otherwise, it starts with a friction of 0.5, a bounce of 0.3, a damping of 0.1 and 0.3 and the standard gravity. Fast objects are swept along their path on every step, so they do not pass through thin walls.
The object belongs to the script that created it. A3D_OnCollided and A3D_OnStopped are called in that script, and the object is destroyed when that script unloads.
Drops a traffic cone with the physics the game gives it.
public OnPlayerCommandText(playerid, cmdtext[]) {
if (strcmp(cmdtext, "/cone", true) == 0) {
new
Float:x,
Float:y,
Float:z,
Float:mass,
Float:bounce,
Float:buoyancy,
Float:damping,
Physic:cone
;
GetPlayerPos(playerid, x, y, z);
A3D_GetModelPhysics(1238, mass, bounce, buoyancy, damping);
cone = A3D_CreateObject(1238, x, y + 2.0, z + 1.0, 0.0, 0.0, 0.0, mass, GetPlayerVirtualWorld(playerid));
if (cone == INVALID_PHYSIC_ID) {
return 1;
}
A3D_SetBounce(cone, bounce);
A3D_SetDamping(cone, damping, 0.3);
return 1;
}
return 0;
}- A3D_CreateSphere: Create a moving physics object shaped like a sphere.
- A3D_CreateBox: Create a moving physics object shaped like a box.
- A3D_CreateStaticObject: Create a physics object that never moves, shaped like the collision of a model.
- A3D_GetModelPhysics: Find how the game moves a model that can be knocked over, such as a bin or a crate, in the values the natives of this include take.
- A3D_AttachDynamicObject: Show a moving physics object with a streamer object instead of a global object.
- A3D_DestroyObject: Destroy a physics object, a static object or a zone, and the global object that shows it.
3DAndreas 0.7.1 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Physics objects
- Model settings
- World queries
- The screen
- Routes
- Navigation mesh
- Map database
- Coming from ColAndreas
- Performance
Reference
Functions