refactor: better attraction

This commit is contained in:
cha0s 2019-10-07 06:29:40 -05:00
parent a147b3f7d2
commit c14f167456
2 changed files with 5 additions and 2 deletions

View File

@ -72,8 +72,8 @@ export class Magnetic extends decorate(Trait) {
}
const difference = Vector.sub(this.entity.position, entity.position);
const unit = Vector.normalize(difference);
const rdiff = 1 - (distance / attraction);
const magnitude = 50 * rdiff;
const rdiff = Math.max(0.4, 1 - (distance / attraction));
const magnitude = 100 * rdiff;
entity.applyMovement(Vector.scale(unit, magnitude));
}
}

View File

@ -55,6 +55,9 @@ export function createEntityForConnection(socket) {
params: {
isAttractor: true,
},
state: {
attraction: 20,
}
},
mobile: {
state: {