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
파일 보기 프로젝트 열기: prime31/Nez 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
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