Teleport entities when they are far from their target position
This commit is contained in:
parent
2cc00f086b
commit
5f725a843b
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue