Repository navigation
Other Components
Other open.mp components can use the map and the bodies of 3DAndreas in C++, through include/3DAndreas.hpp. A damage component can check for walls between a shooter and a target, or an NPC component can find the ground under a point, without going through Pawn.
#include "3DAndreas.hpp"
A3D::IComponent3DAndreas* physics = nullptr;
void onInit(IComponentList* components) override {
physics = components->queryComponent<A3D::IComponent3DAndreas>();
}
bool canSee(Vector3 from, Vector3 to) {
return physics == nullptr || physics->isLineOfSight(from, to, -1, A3D::CollideMap | A3D::CollideObjects);
}queryComponent gives nullptr when 3DAndreas is not loaded, so the other component keeps working without it.
| Call | What it does |
|---|---|
isLineOfSight(from, to, world, flags) |
Whether nothing of the kinds in flags lies between two points. |
castRay(from, to, world, flags, hit) |
The first thing a segment touches: its point, the side of the surface facing the ray, what it is, its id in Pawn and its surface. |
findGround(point, depth, world, flags, z) |
The height of the first surface under a point, at most depth below it. |
world is a virtual world, or -1 for every world. flags takes the values of Collision flags, which A3D::Collide names in C++. hit.type takes the values of Hit types.
Every call reads the world the server steps on its main thread, so it is made from that thread: in a tick, an event or a native, never from a worker thread.
3DAndreas 0.7.6 · Repository · Releases · MIT License
Guides
- Installation
- Configuration
- Physics objects
- Model settings
- World queries
- The screen
- Routes
- Navigation mesh
- Map database
- Other components
- Coming from ColAndreas
- Performance
Reference
Functions