Class PhysicsBody
Creates a Box2D body and keeps its GameObject transform synchronized.
public sealed class PhysicsBody : Component, IDisposable
- Inheritance
-
PhysicsBody
- Implements
- Inherited Members
Constructors
PhysicsBody(GameObject, PhysicsWorld)
Creates a Box2D body and keeps its GameObject transform synchronized.
public PhysicsBody(GameObject gameObject, PhysicsWorld world)
Parameters
gameObjectGameObjectworldPhysicsWorld
Properties
AngularDamping
public float AngularDamping { get; set; }
Property Value
BodyId
public B2BodyId BodyId { get; }
Property Value
- B2BodyId
GravityScale
public float GravityScale { get; set; }
Property Value
HasBody
public bool HasBody { get; }
Property Value
IsBullet
public bool IsBullet { get; set; }
Property Value
LinearDamping
public float LinearDamping { get; set; }
Property Value
LinearVelocity
public Vector2 LinearVelocity { get; set; }
Property Value
ShapeCount
public int ShapeCount { get; }
Property Value
Type
public B2BodyType Type { get; set; }
Property Value
- B2BodyType
Methods
AddBox(Vector2, float, float, float)
public void AddBox(Vector2 size, float density = 1, float friction = 0.6, float restitution = 0)
Parameters
AddCircle(float, float, float, float)
public void AddCircle(float radius, float density = 1, float friction = 0.6, float restitution = 0)
Parameters
ApplyForce(Vector2)
public void ApplyForce(Vector2 force)
Parameters
forceVector2
ApplyLinearImpulse(Vector2)
public void ApplyLinearImpulse(Vector2 impulse)
Parameters
impulseVector2
OnDestroy()
public override void OnDestroy()
OnDisable()
public override void OnDisable()
OnEnable()
public override void OnEnable()
Start()
public override void Start()
Teleport(Vector2, float)
public void Teleport(Vector2 worldPosition, float rotation)
Parameters
Events
CollisionEntered
public event Action<PhysicsBody>? CollisionEntered
Event Type
CollisionExited
public event Action<PhysicsBody>? CollisionExited