Returns the distance between this entity and a specific location.
Usage
body:distance_to(x,y)
Arguments
Name
Type
Description
x
number
x component of the location.
y
number
y component of the location.
Returns
Name
Type
Description
distance
number
Distance to the specified location.
Examples
localecs=crystal.ECS:new();ecs:add_system(crystal.PhysicsSystem);localhero=ecs:spawn(crystal.Entity);hero:add_component(crystal.Body);hero:set_position(0,0);print(hero:distance_to(10,0));-- Prints "10"