You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 rivejä
433 B

  1. module.exports = async (cpnSocial, targetName) => {
  2. const { obj } = cpnSocial;
  3. const { instance: { objects, physics }, syncer } = obj;
  4. const target = objects.find(o => o.name && o.name.toLowerCase().includes(targetName.toLowerCase()));
  5. if (!target)
  6. return;
  7. physics.removeObject(obj, obj.x, obj.y);
  8. obj.x = target.x;
  9. obj.y = target.y;
  10. physics.addObject(obj, obj.x, obj.y);
  11. syncer.o.x = obj.x;
  12. syncer.o.y = obj.y;
  13. };