C# Class Nez.ArcadeRigidbody

Note that this is not a full, multi-iteration physics system! This can be used for simple, arcade style physics. Based on http://elancev.name/oliver/2D%20polygon.htm#tut5
Inheritance: Component, IUpdatable
Afficher le fichier Open project: prime31/Nez Class Usage Examples

Méthodes publiques

Свойство Type Description
shouldUseGravity bool
velocity Vector2

Méthodes publiques

Méthode Description
ArcadeRigidbody ( ) : System
IUpdatable ( ) : void
addImpulse ( Vector2 force ) : void

add an instant force impulse to the rigidbody using its mass. force is an acceleration in pixels per second per second. The force is multiplied by 100000 to make the values more reasonable to use.

calculateResponseVelocity ( Vector2 &relativeVelocity, Vector2 &minimumTranslationVector, Vector2 &responseVelocity ) : void

given the relative velocity between the two objects and the MTV this method modifies the relativeVelocity to make it a collision response.

onAddedToEntity ( ) : void
processCollision ( ArcadeRigidbody other, Vector2 &minimumTranslationVector ) : void

handles the collision of two non-overlapping rigidbodies. New velocities will be assigned to each rigidbody as appropriate.

processOverlap ( ArcadeRigidbody other, Vector2 &minimumTranslationVector ) : void

separates two overlapping rigidbodies. Handles the case of either being immovable as well.

setElasticity ( float value ) : ArcadeRigidbody

0 - 1 range where 0 is no bounce and 1 is perfect reflection

setFriction ( float value ) : ArcadeRigidbody

0 - 1 range. 0 means no friction, 1 means the object will stop dead on

setGlue ( float value ) : ArcadeRigidbody

0 - 9 range. When a collision occurs and it has risidual motion along the surface of collision if its square magnitude is less than glue friction will be set to the maximum for the collision resolution.

setMass ( float mass ) : ArcadeRigidbody

mass of this rigidbody. A 0 mass will make this an immovable object.

setVelocity ( Vector2 velocity ) : ArcadeRigidbody

velocity of this rigidbody

Method Details

ArcadeRigidbody() public méthode

public ArcadeRigidbody ( ) : System
Résultat System

IUpdatable() public méthode

public IUpdatable ( ) : void
Résultat void

addImpulse() public méthode

add an instant force impulse to the rigidbody using its mass. force is an acceleration in pixels per second per second. The force is multiplied by 100000 to make the values more reasonable to use.
public addImpulse ( Vector2 force ) : void
force Vector2 Force.
Résultat void

calculateResponseVelocity() public méthode

given the relative velocity between the two objects and the MTV this method modifies the relativeVelocity to make it a collision response.
public calculateResponseVelocity ( Vector2 &relativeVelocity, Vector2 &minimumTranslationVector, Vector2 &responseVelocity ) : void
relativeVelocity Vector2 Relative velocity.
minimumTranslationVector Vector2 Minimum translation vector.
responseVelocity Vector2
Résultat void

onAddedToEntity() public méthode

public onAddedToEntity ( ) : void
Résultat void

processCollision() public méthode

handles the collision of two non-overlapping rigidbodies. New velocities will be assigned to each rigidbody as appropriate.
public processCollision ( ArcadeRigidbody other, Vector2 &minimumTranslationVector ) : void
other ArcadeRigidbody Other.
minimumTranslationVector Vector2
Résultat void

processOverlap() public méthode

separates two overlapping rigidbodies. Handles the case of either being immovable as well.
public processOverlap ( ArcadeRigidbody other, Vector2 &minimumTranslationVector ) : void
other ArcadeRigidbody Other.
minimumTranslationVector Vector2
Résultat void

setElasticity() public méthode

0 - 1 range where 0 is no bounce and 1 is perfect reflection
public setElasticity ( float value ) : ArcadeRigidbody
value float Value.
Résultat ArcadeRigidbody

setFriction() public méthode

0 - 1 range. 0 means no friction, 1 means the object will stop dead on
public setFriction ( float value ) : ArcadeRigidbody
value float Value.
Résultat ArcadeRigidbody

setGlue() public méthode

0 - 9 range. When a collision occurs and it has risidual motion along the surface of collision if its square magnitude is less than glue friction will be set to the maximum for the collision resolution.
public setGlue ( float value ) : ArcadeRigidbody
value float Value.
Résultat ArcadeRigidbody

setMass() public méthode

mass of this rigidbody. A 0 mass will make this an immovable object.
public setMass ( float mass ) : ArcadeRigidbody
mass float Mass.
Résultat ArcadeRigidbody

setVelocity() public méthode

velocity of this rigidbody
public setVelocity ( Vector2 velocity ) : ArcadeRigidbody
velocity Vector2 Velocity.
Résultat ArcadeRigidbody

Property Details

shouldUseGravity public_oe property

if true, Physics.gravity will be taken into account each frame
public bool shouldUseGravity
Résultat bool

velocity public_oe property

velocity of this rigidbody
public Vector2 velocity
Résultat Vector2