Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void moveTowards(Entity ent, Entity targ, float speed) {
- double vecX = targ.posX - ent.posX;
- double vecY = targ.posY - ent.posY;
- double vecZ = targ.posZ - ent.posZ;
- double dist2 = (double)Math.sqrt(vecX * vecX + vecY * vecY + vecZ * vecZ);
- ent.motionX += vecX / dist2 * speed;
- ent.motionY += vecY / dist2 * speed;
- ent.motionZ += vecZ / dist2 * speed;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement