Description
Calculate distance
Credits
These scripts were written by GlitchyTurtle32
Click the link above for source code of the script.
·
1 messages · Page 1 of 1 (latest)
Description
Calculate distance
Credits
These scripts were written by GlitchyTurtle32
pythagoras theorem
world.afterEvents.entityHit.subscribe((event) => {
const location1 = {
x: event.entity.location.x,
y: event.entity.location.y,
z: event.entity.location.z,
};
const location2 = {
x: event.hitEntity.location.x,
y: event.hitEntity.location.y,
z: event.hitEntity.location.z,
};
const distance = Math.pow(
Math.pow(location2.x - location1.x, 2) +
Math.pow(location2.y - location1.y, 2) +
Math.pow(location2.z - location1.z, 2),
0.5
);
});```
Just put the function in, and pass the two entities positions as args to the function on hit
It’s not super complicated my man. Just subscribe to entity hit, then calculateDistance(hitEntity, entity)
i already got it
Ok, so why this?