physics
FreeBodyEngine.core.physics
#
PhysicsBody(position=Vector(), rotation=0.0, scale=Vector(1, 1), mass=1, velocity=Vector(0, 0), rotational_velocity=0.0, friction=0.98)
#
Bases: Node2D
A basic arcade physics object.
:param position: The world position of the body. :type position: Vector
:param collider: The colider object used for the body's collisions. :type collider: Collider
:param mass: The mass of the body. :type mass: int
:param velocity: The starting velocity of body. :type velocity: Vector
:param friction: The friction that will be applied to the body. :type friction: float
Sets up the body's starting motion state and requires a sibling Collider2D (declared in self.requirements) for collision checks.
accumulated_acceleration = Vector()
instance-attribute
#
forces = Vector()
instance-attribute
#
friction = friction
instance-attribute
#
mass = mass
instance-attribute
#
requirements = ['Collider2D']
instance-attribute
#
rot_forces = 0
instance-attribute
#
rot_vel = rotational_velocity
instance-attribute
#
vel = velocity
instance-attribute
#
apply_acceleration(acceleration)
#
Applies a mass-independent acceleration to the body (unlike apply_force(), this isn't divided by mass during integration).
apply_force(force)
#
Applies a force to the physics body.
:param force: The force that will be applied to the body. :type force: vector
apply_rotation_force(force)
#
Applies a rotational force (torque) to the body.
on_collision(collider, other)
#
Called after a collision with other has been resolved - override to react to collisions (e.g. play a sound, take damage).
on_physics_process()
#
Called once per physics step - override to run custom per-step physics logic.