|
Nebula
|
The managed side of the physics feature.
A body is named by the uint the PhysicsActor component holds, which is an id into the native actor pool. A script can hold an id across a rebuild and the entity it named can be gone by the time the call comes back, so the calls answer with an invalid value rather than asserting.
PhysX only allows reads of a body before simulate() and writes after fetchResults(), which is what the physics frame event is. The managed phase runs inside that event, after the step, so a read here sees this step and a write is picked up by the next one. A property that wants this phase can just override OnPhysicsFrame
Classes | |
| class | Native |
Static Public Member Functions | |
| static bool | IsActorValid (uint actorId) |
| Whether the id is in the actor pool. | |
| static float | GetMass (uint actorId) |
| The mass the body has. | |
| static bool | IsSleeping (uint actorId) |
| static void | WakeUp (uint actorId) |
| static void | Sleep (uint actorId) |
| static Vector3 | GetVelocity (uint actorId) |
| static void | SetVelocity (uint actorId, Vector3 velocity) |
| static Vector3 | GetAngularVelocity (uint actorId) |
| static void | SetAngularVelocity (uint actorId, Vector3 angularVelocity) |
| static void | AddForce (uint actorId, Vector3 force) |
| Newtons. | |
| static void | AddImpulse (uint actorId, Vector3 impulse) |
| Mass times the velocity change. | |
| static void | AddImpulseAtPoint (uint actorId, Vector3 impulse, Vector3 point) |
| Impulse at a point in world space, which is what gives the body angular velocity as well. | |
| static void | AddTorque (uint actorId, Vector3 torque) |
| static uint | GetSceneForWorld (uint worldId) |
| The physics scene a game world has. | |
| static QueryFilter | NewQueryFilter (uint group=0, uint mask=0xFFFFFFFF, uint excludeActorId=InvalidActorId) |
| A filter with the values the native struct starts with. | |
| static bool | Raycast (Vector3 origin, Vector3 direction, float maxDistance, ref RaycastHit hit) |
| Closest hit along a ray, on the default scene with a filter that accepts everything. | |
| static bool | Raycast (Vector3 origin, Vector3 direction, float maxDistance, ref RaycastHit hit, ref QueryFilter filter) |
| static bool | Raycast (uint scene, Vector3 origin, Vector3 direction, float maxDistance, ref RaycastHit hit, ref QueryFilter filter) |
| static bool | SegmentCast (Vector3 from, Vector3 to, ref RaycastHit hit) |
| Closest hit along a segment, on the default scene with a filter that accepts everything. | |
| static bool | SegmentCast (Vector3 from, Vector3 to, ref RaycastHit hit, ref QueryFilter filter) |
| static bool | SegmentCast (uint scene, Vector3 from, Vector3 to, ref RaycastHit hit, ref QueryFilter filter) |
| static bool | SphereCast (Vector3 center, float radius, Vector3 direction, float maxDistance, ref ShapeCastHit hit) |
| Closest hit along a swept sphere, on the default scene with a filter that accepts everything. | |
| static bool | SphereCast (Vector3 center, float radius, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | SphereCast (uint scene, Vector3 center, float radius, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | SphereCastAny (Vector3 center, float radius, Vector3 direction, float maxDistance, ref ShapeCastHit hit) |
| First hit found along a swept sphere, which is not necessarily the closest. | |
| static bool | SphereCastAny (Vector3 center, float radius, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | SphereCastAny (uint scene, Vector3 center, float radius, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | BoxCast (Vector3 center, Quaternion orientation, Vector3 halfExtents, Vector3 direction, float maxDistance, ref ShapeCastHit hit) |
| Closest hit along a swept box, on the default scene with a filter that accepts everything. | |
| static bool | BoxCast (Vector3 center, Quaternion orientation, Vector3 halfExtents, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | BoxCast (uint scene, Vector3 center, Quaternion orientation, Vector3 halfExtents, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | BoxCastAny (Vector3 center, Quaternion orientation, Vector3 halfExtents, Vector3 direction, float maxDistance, ref ShapeCastHit hit) |
| First hit found along a swept box, which is not necessarily the closest. | |
| static bool | BoxCastAny (Vector3 center, Quaternion orientation, Vector3 halfExtents, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | BoxCastAny (uint scene, Vector3 center, Quaternion orientation, Vector3 halfExtents, Vector3 direction, float maxDistance, ref ShapeCastHit hit, ref QueryFilter filter) |
| static bool | IsCharacterValid (uint characterId) |
| Whether the id is in the controller pool. | |
| static Vector3 | GetCharacterFootPosition (uint characterId) |
| The lowest point of the character's collider in world space, which is what the entity's Position component holds. | |
| static Vector3 | GetCharacterCenterPosition (uint characterId) |
| The center of the character's collider in world space. | |
| static uint | MoveCharacter (uint characterId, Vector3 displacement, float minDist, float timeSinceLastMove) |
| The collision bits the move answered with. | |
| static void | SetCharacterPosition (uint characterId, Vector3 footPosition) |
| Move the character to a foot position without checking for collisions. | |
| static void | SetCharacterHeight (uint characterId, float newHeight) |
| Resize the character. | |
Static Public Attributes | |
| const uint | InvalidActorId = 0xFFFFFFFF |
| const uint | InvalidScene = 0xFFFFFFFF |
| const uint | InvalidCharacterId = 0xFFFFFFFF |
| const uint | CharacterCollisionSides = 1 << 0 |
| const uint | CharacterCollisionUp = 1 << 1 |
| const uint | CharacterCollisionDown = 1 << 2 |
Properties | |
| static uint | DefaultScene [get] |
| The physics scene the default world has. | |
Static Private Attributes | |
| static uint | defaultScene = InvalidScene |
Newtons.
The force is accumulated by the body and integrated by the next step, so it is not the same quantity as an impulse.
Mass times the velocity change.
A call here is what a step applies to the body immediately, which is the quantity a jump or a bounce is usually written in.
|
inlinestatic |
Impulse at a point in world space, which is what gives the body angular velocity as well.
|
inlinestatic |
|
inlinestatic |
Closest hit along a swept box, on the default scene with a filter that accepts everything.
The orientation is the orientation of the box at the start of the cast, and the box does not rotate while it is swept. Distance is measured from the center of the box, so a box with half extents of 1 whose center is 5 from a surface reports 4. See the remarks on SphereCast for what a hit that started inside geometry answers with.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
First hit found along a swept box, which is not necessarily the closest.
See the remarks on SphereCastAny.
|
inlinestatic |
The center of the character's collider in world space.
The lowest point of the character's collider in world space, which is what the entity's Position component holds.
|
inlinestatic |
The mass the body has.
This is the mass PhysX resolved, which is not the same as the Rigidbody component's mass: the component defaults to 0 and the mass is then derived from the shape volumes and the material densities.
The physics scene a game world has.
|
inlinestatic |
Whether the id is in the actor pool.
A static, kinematic or dynamic actor is in it, and an entity that has a PhysicsActor component but has not been built yet is not.
|
inlinestatic |
Whether the id is in the controller pool.
An entity with a Character component that has not been built yet is not, because the component is filled by the feature on the physics frame.
|
inlinestatic |
|
inlinestatic |
The collision bits the move answered with.
Bit 0 is sides, bit 1 up and bit 2 down, and the down bit is what a grounded check reads.
A character controller is moved by a displacement, not by a velocity, and the move happens outside the step. The character's actor is in the actor pool, but its velocity is not what the controller moved by, so a character is read through its component rather than through the velocity calls.
|
inlinestatic |
A filter with the values the native struct starts with.
A C# struct cannot give its fields default values, so a new QueryFilter() has mask 0 and excludeActorId 0. Native starts with every group accepted and no actor excluded, which is not what a fresh struct gives, so build a filter with this rather than with new.
|
inlinestatic |
|
inlinestatic |
Closest hit along a ray, on the default scene with a filter that accepts everything.
The direction has to be normalized. A ground check needs a filter that excludes its own actor, because the ray starts inside the shape the caller owns.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Closest hit along a segment, on the default scene with a filter that accepts everything.
The segment is the direction and the distance, so a caller that has two points does not have to normalize them first.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Resize the character.
The position is adjusted so it does not pop into the air.
|
inlinestatic |
Move the character to a foot position without checking for collisions.
This is a teleport, so a character placed inside geometry stays there until the next move.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
Closest hit along a swept sphere, on the default scene with a filter that accepts everything.
Distance is how far the shape travelled, measured from its center rather than from its surface, so a radius 1 sphere whose center is 5 from a surface reports 4. The hit point is the contact point, which is a different number. A shape that already overlaps geometry at the start reports distance 0, and its normal is the reverse of the cast direction rather than a surface normal. A box cast is a few thousandths short, because PhysX uses an edge tolerance for a box against a box.
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
First hit found along a swept sphere, which is not necessarily the closest.
This is the fast path for a caller that only needs to know that something is in the way, such as a line of sight check. Use SphereCast when the caller needs the closest hit or the distance.
|
inlinestatic |
|
inlinestatic |
|
static |
|
static |
|
static |
|
staticprivate |
|
static |
|
static |
|
static |
|
staticget |
The physics scene the default world has.