Body:set_rotation

Sets this entity’s rotation. A rotation of 0 indicates an entity facing right. Positive values indicate clockwise rotation.

Rotating Body components does not rotate the underlying love.Body. This allows colliders and sensors to remain upright no matter what direction the entity is facing.

Usage

body:set_rotation(rotation)

Arguments

Name Type Description
rotation number Rotation in radians.

Examples

local ecs = crystal.ECS:new();
ecs:add_system(crystal.PhysicsSystem);

local hero = ecs:spawn(crystal.Entity);
hero:add_component(crystal.Body);
hero:set_rotation(math.pi);
print(hero:rotation()); -- Prints "3.1415..."

This site uses Just the Docs, a documentation theme for Jekyll.