pyunity.physics.core module¶
Core classes of the PyUnity physics engine.
-
class
pyunity.physics.core.
AABBoxCollider
[source]¶ Bases:
pyunity.physics.core.Collider
An axis-aligned box collider that cannot be deformed.
-
Move
(dt)[source]¶ Moves the whole collider by its velocity times the delta time.
- Parameters
dt (float) – Delta time to move the velocity by
-
collidingWith
(other)[source]¶ Check to see if the collider is colliding with another collider.
- Parameters
other (Collider) – Other collider to check against
- Returns
Collision data
- Return type
Manifold or None
Notes
To check against another AABBoxCollider, the corners are checked to see if they are inside the other collider.
To check against a SphereCollider, the check is as follows:
The sphere’s center is checked to see if it is inside the AABB.
If it is, then the two are colliding.
If it isn’t, then a copy of the position is clamped to the AABB’s bounds.
Finally, the distance between the clamped position and the original position is measured.
If the distance is bigger than the sphere’s radius, then the two are colliding.
If not, then they aren’t colliding.
-
-
class
pyunity.physics.core.
CollManager
[source]¶ Bases:
object
Manage the collisions between all colliders.
-
AddColliders
(scene)[source]¶ Get all colliders from a specified scene. This overwrites the collider list, and so can be called whenever a new collider is added or removed.
-
-
class
pyunity.physics.core.
Collider
[source]¶ Bases:
pyunity.core.Component
Collider base class. The default mass is 100.
-
class
pyunity.physics.core.
Manifold
(a, b, normal, penetration)[source]¶ Bases:
object
Class to store collision data.
-
class
pyunity.physics.core.
PhysicMaterial
(restitution=0.75, friction=1)[source]¶ Bases:
object
Class to store data on a collider’s material.
- Parameters
restitution (float) – Bounciness of the material
friction (float) – Friction of the material
-
class
pyunity.physics.core.
SphereCollider
[source]¶ Bases:
pyunity.physics.core.Collider
A spherical collider that cannot be deformed.
-
Move
(dt)[source]¶ Moves the whole collider by its velocity times the delta time.
- Parameters
dt (float) – Delta time to move the velocity by
-
SetSize
(radius, offset)[source]¶ Sets the size of the collider.
- Parameters
radius (float) – The radius of the collider.
offset (Vector3) – Offset of the collider.
-
collidingWith
(other)[source]¶ Check to see if the collider is colliding with another collider.
- Parameters
other (Collider) – Other collider to check against
- Returns
Collision data
- Return type
Manifold or None
Notes
To check against another SphereCollider, the distance and the sum of the radii is checked.
To check against an AABBoxColider, the check is as follows:
The sphere’s center is checked to see if it is inside the AABB.
If it is, then the two are colliding.
If it isn’t, then a copy of the position is clamped to the AABB’s bounds.
Finally, the distance between the clamped position and the original position is measured.
If the distance is bigger than the sphere’s radius, then the two are colliding.
If not, then they aren’t colliding.
-
-
pyunity.physics.core.
infinity
= inf¶ A representation of infinity