-
Notifications
You must be signed in to change notification settings - Fork 1
Physics.PhysicsEntity
Namespace: Verdant.Physics
public class PhysicsEntity : Entity
An Entity with collider and additional physical properties, which can collide with other PhysicsEntities and be simulated by the EntityManager.
Navigate
Property | Description |
---|---|
Components | The Shapes that make up the PhysicsEntity's collider. |
Position | The position of the PhysicsEntity (the center of its first Shape component). |
Mass | The mass of the PhysicsEntity. |
InvMass | |
Inertia | The inertia of the PhysicsEntity, calculated from mass. |
InvInertia | |
Velocity | The velocity of the PhysicsEntity. |
Acceleration | The acceleration of the PhysicsEntity. |
Speed | The speed multiplier applied to acceleration when the PhysicsEntity moves. |
Friction | The friction of the PhysicsEntity. |
AngleSpeed | The speed at which the PhysicsEntity is currently rotating. |
AngleFriction | The friction of the PhysicsEntity's rotation. |
Elasticity | The elasticity of the PhysicsEntity when a collision is resolved. |
Trigger | Determines if the PhysicsEntity is a trigger. Collisions with triggers will not be resolved, but will still be registered. |
BodyColor | The color to render the PhysicsEntity's Shape components when visualizing bodies. |
Colliding |
public PhysicsEntity(RenderObject sprite, Vec2 position, float width, float height, float mass) : base(sprite, position, (int)width, (int)height)
Initialize a new PhysicsEntity. By default, it will have a mass but no Components. In most cases, it is more appropriate to use an extension like a BallEntity or BoxEntity.
Parameter | Description |
---|---|
RenderObject sprite
|
|
Vec2 position
|
|
float width
|
|
float height
|
|
float mass
|
public virtual void Move()
Perform physics movement for the Body.
public List<TPhysicsEntity> GetColliding<TPhysicsEntity>(bool includeTriggers = true, bool includeSolids = true) where TPhysicsEntity : PhysicsEntity
Get a list of all PhysicsEntities of a given type currently colliding with this Entity.
Returns: A list of all PhyiscsEntities currently colliding with this one.
Type Parameter | Description |
---|---|
TPhysicsEntity |
The type of PhysicsEntity to check for. |
Parameter | Description |
---|---|
bool includeTriggers = true
|
Include PhysicsEntities that are triggers. |
bool includeSolids = true
|
Include PhysicsEntities that are not triggers. |
public List<PhysicsEntity> GetColliding(bool includeTriggers = true, bool includeSolids = true)
Get a list of all PhysicsEntities currently colliding with this Entity.
Returns: A list of all PhysicsEntities currently colliding with this one.
Parameter | Description |
---|---|
bool includeTriggers = true
|
Include PhysicsEntities that are triggers. |
bool includeSolids = true
|
Include PhysicsEntities that are not triggers. |
public virtual void DrawBody(SpriteBatch spriteBatch)
Visualize the Components of the Body according to the BodyColor. The default implementation is only intended for debug purposes as some draw calls, particularly for Circles are highly inefficient.
Parameter | Description |
---|---|
SpriteBatch spriteBatch
|
The SpriteBatch to draw with. |
The Verdant wiki is automatically generated from documentation comments in the codebase by markify.