C# Класс 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
Наследование: Component, IUpdatable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
shouldUseGravity bool
velocity Vector2

Открытые методы

Метод Описание
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

Описание методов

ArcadeRigidbody() публичный Метод

public ArcadeRigidbody ( ) : System
Результат System

IUpdatable() публичный Метод

public IUpdatable ( ) : void
Результат void

addImpulse() публичный Метод

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.
Результат void

calculateResponseVelocity() публичный Метод

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
Результат void

onAddedToEntity() публичный Метод

public onAddedToEntity ( ) : void
Результат void

processCollision() публичный Метод

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
Результат void

processOverlap() публичный Метод

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
Результат void

setElasticity() публичный Метод

0 - 1 range where 0 is no bounce and 1 is perfect reflection
public setElasticity ( float value ) : ArcadeRigidbody
value float Value.
Результат ArcadeRigidbody

setFriction() публичный Метод

0 - 1 range. 0 means no friction, 1 means the object will stop dead on
public setFriction ( float value ) : ArcadeRigidbody
value float Value.
Результат ArcadeRigidbody

setGlue() публичный Метод

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.
Результат ArcadeRigidbody

setMass() публичный Метод

mass of this rigidbody. A 0 mass will make this an immovable object.
public setMass ( float mass ) : ArcadeRigidbody
mass float Mass.
Результат ArcadeRigidbody

setVelocity() публичный Метод

velocity of this rigidbody
public setVelocity ( Vector2 velocity ) : ArcadeRigidbody
velocity Vector2 Velocity.
Результат ArcadeRigidbody

Описание свойств

shouldUseGravity публичное свойство

if true, Physics.gravity will be taken into account each frame
public bool shouldUseGravity
Результат bool

velocity публичное свойство

velocity of this rigidbody
public Vector2 velocity
Результат Vector2