Class Rigidbody
Class for the entities which apply general physics by the system
Fields
CollisionMask
Which physics layers should this entity collide with
Declaration
public readonly FrameBasedInt CollisionMask
FallingGravityScale
Amount of gravity apply to this entity when it's moving downward (0 means 0%, 1000 means 100%)
Declaration
public readonly FrameBasedInt FallingGravityScale
GlobalGravity
Gravity value that applys to all rigidbody
Declaration
public static readonly FrameBasedInt GlobalGravity
IgnoreGravity
True if this entity currently should not apply gravity
Declaration
public readonly FrameBasedBool IgnoreGravity
IgnoreGroundCheck
If this entity currently check for touching ground
Declaration
public readonly FrameBasedBool IgnoreGroundCheck
IgnoreInsideGround
If this entity currently check for stuck inside ground
Declaration
public readonly FrameBasedBool IgnoreInsideGround
IgnoreMomentum
True if this entity currently should not apply any momentum
Declaration
public readonly FrameBasedBool IgnoreMomentum
IgnoreOneway
True if this entity currently should not collide with oneway gates
Declaration
public readonly FrameBasedBool IgnoreOneway
IgnorePhysics
True if this entity currently should not apply any physics logic
Declaration
public readonly FrameBasedBool IgnorePhysics
MomentumX
Velocity X that keep applying on this entity. Every frame the value will move to 0 by "decay"
Declaration
public (int value, int decay) MomentumX
MomentumY
Velocity Y that keep applying on this entity. Every frame the value will move to 0 by "decay"
Declaration
public (int value, int decay) MomentumY
RisingGravityScale
Amount of gravity apply to this entity when it's moving upward (0 means 0%, 1000 means 100%)
Declaration
public readonly FrameBasedInt RisingGravityScale
Properties
AirDragX
Amount of horizontal speed lost every frame
Declaration
public virtual int AirDragX { get; }
AirDragY
Amount of vertical speed lost every frame
Declaration
public virtual int AirDragY { get; }
AllowBeingPush
True if this entity can be push by other
Declaration
public virtual bool AllowBeingPush { get; }
BounceSpeedRate
How many speed remain after this entity collide on another entity (0 means 0%, 1000 means 100%)
Declaration
public int BounceSpeedRate { get; set; }
CarryOtherOnTop
Trhe if this entity can carry other ICarrier on top
Declaration
public virtual bool CarryOtherOnTop { get; }
DeltaPositionX
Changes of position X at current frame in global space
Declaration
public int DeltaPositionX { get; }
DeltaPositionY
Changes of position Y at current frame in global space
Declaration
public int DeltaPositionY { get; }
DestroyWhenInsideGround
True if this entity despawns when it's inside ground
Declaration
public virtual bool DestroyWhenInsideGround { get; }
EjectWhenInsideGround
True if this entity try to move out of ground automatically when it stuck inside ground
Declaration
public virtual bool EjectWhenInsideGround { get; }
FacingRight
True if this entity is facing right side
Declaration
public virtual bool FacingRight { get; }
GroundedID
Block ID of the current touching ground block
Declaration
public int GroundedID { get; set; }
InWater
True if this entity is inside water
Declaration
public bool InWater { get; }
IsGrounded
True if this entity is touching ground
Declaration
public bool IsGrounded { get; protected set; }
IsInsideGround
True if this entity is stucking inside the ground
Declaration
public bool IsInsideGround { get; }
MaxGravitySpeed
Limitation for speed from gravity
Declaration
public virtual int MaxGravitySpeed { get; }
OffsetX
Position offset between X value and Rect.x value
Declaration
public int OffsetX { get; set; }
OffsetY
Position offset between Y value and Rect.y value
Declaration
public int OffsetY { get; set; }
PhysicalLayer
Which physical layer should this entity fill it's collider in
Declaration
public virtual int PhysicalLayer { get; }
PrevX
Position X for the last frame in global space
Declaration
public int PrevX { get; }
PrevY
Position Y for the last frame in global space
Declaration
public int PrevY { get; }
Rect
Rect position of this entity in global space
Declaration
public override IRect Rect { get; }
Overrides
RequireDodgeOverlap
True if this entity do not react to the colliders which already overlaps on it.
Declaration
public bool RequireDodgeOverlap { get; set; }
SelfCollisionMask
Intrinsic physics layers this entity should collide with
Declaration
public virtual int SelfCollisionMask { get; }
VelocityX
Horizontal velocity at current frame
Declaration
public int VelocityX { get; set; }
VelocityY
Vertical velocity at current frame
Declaration
public int VelocityY { get; set; }
WaterFloatSpeed
Amount of upward speed apply when the entity inside water
Declaration
public virtual int WaterFloatSpeed { get; }
WaterSpeedRate
Amount of speed scales when entity inside water (0 means 0%, 1000 means 100%)
Declaration
public virtual int WaterSpeedRate { get; }
Methods
CancelMakeGrounded()
Stop making this entity marked as touching ground
Declaration
public void CancelMakeGrounded()
FillAsOnewayUp(int, int)
Make this entity fill upward oneway gate into the physics system for given frames long
Declaration
public void FillAsOnewayUp(int duration = 0, int priority = 0)
FillAsTrigger(int, int)
Make this entity fill trigger into the physics system for given frames long
Declaration
public void FillAsTrigger(int duration = 0, int priority = 0)
FirstUpdate()
[1/4] This function is called every frame when entity is in stage. Prioritize using this function to fill collider in to physics system.
Declaration
public override void FirstUpdate()
Overrides
GroundedCheck()
Function that holds the touching ground checking logic
Declaration
protected virtual bool GroundedCheck()
InsideGroundCheck()
Function that holds the stuck inside ground checking logic
Declaration
protected virtual bool InsideGroundCheck()
MakeGrounded(int, int)
Mark this entity as touching ground for given frames long
Declaration
public void MakeGrounded(int frame = 1, int blockID = 0)
Ground block ID
OnActivated()
This function is called when entity enter the stage
Declaration
public override void OnActivated()
Overrides
OnInsideGroundDestroyed()
This function is called when this entity is despawn by being stuck inside ground
Declaration
protected virtual void OnInsideGroundDestroyed()
PerformGroundCheck(IRect, out PhysicsCell)
Return true if the entity is touching ground
Declaration
public bool PerformGroundCheck(IRect rect, out PhysicsCell hit)
Parameters
Type | Name | Description |
---|---|---|
IRect | rect | Blocks overlap this rect range will be count as touching ground |
PhysicsCell | hit | The physics data from the ground block |
PerformMove(int, int, bool)
Make this entity move with physics rules at this frame
Declaration
public void PerformMove(int speedX, int speedY, bool ignoreCarry = false)
Parameters
Type | Name | Description |
---|---|---|
int | speedX | Delta position X |
int | speedY | Delta position Y |
bool | ignoreCarry | True if this entity don't carry other on top |
Push(int)
This function is called when the entity is being pushed
Declaration
public virtual void Push(int speedX)
RefreshPrevPosition()
Declaration
protected void RefreshPrevPosition()
Update()
[3/4] This function is called every frame when entity is in stage. Prioritize using this function to update physics logic.
Declaration
public override void Update()