Teleport entities when they are far from their target position

This commit is contained in:
Thinkofname 2016-04-21 23:24:01 +01:00
parent 2cc00f086b
commit 5f725a843b
1 changed files with 2 additions and 1 deletions

View File

@ -157,7 +157,8 @@ impl ecs::System for LerpPosition {
let target_pos = m.get_component(e, self.target_position).unwrap();
pos.position = pos.position + (target_pos.position - pos.position) * delta * target_pos.lerp_amount;
if (pos.position - target_pos.position).length2() < 0.001 {
let len = (pos.position - target_pos.position).length2() ;
if len < 0.001 || len > 100.0 * 100.0 {
pos.position = target_pos.position;
}
}