diff --git a/packages/scratch-gui/src/lib/make-toolbox-xml.js b/packages/scratch-gui/src/lib/make-toolbox-xml.js
index 48ce3841784..11b478d939f 100644
--- a/packages/scratch-gui/src/lib/make-toolbox-xml.js
+++ b/packages/scratch-gui/src/lib/make-toolbox-xml.js
@@ -99,6 +99,18 @@ const motion = function (isInitialSetup, isStage, targetId, colors) {
+
+
+
+
+
+
+
+
+
+
+
+
${blockSeparator}
diff --git a/packages/scratch-vm/src/blocks/scratch3_motion.js b/packages/scratch-vm/src/blocks/scratch3_motion.js
index 774c0bbd9b2..9a89af0f7cd 100644
--- a/packages/scratch-vm/src/blocks/scratch3_motion.js
+++ b/packages/scratch-vm/src/blocks/scratch3_motion.js
@@ -35,6 +35,7 @@ class Scratch3MotionBlocks {
motion_xposition: this.getX,
motion_yposition: this.getY,
motion_direction: this.getDirection,
+ motion_pointtowardsxy: this.pointTowardsXY,
// Legacy no-op blocks:
motion_scroll_right: () => {},
motion_scroll_up: () => {},
@@ -275,6 +276,16 @@ class Scratch3MotionBlocks {
return util.target.direction;
}
+ pointTowardsXY (args, util) {
+ let targetX = Cast.toNumber(args.X);
+ let targetY = Cast.toNumber(args.Y);
+
+ const dx = targetX - util.target.x;
+ const dy = targetY - util.target.y;
+ const direction = 90 - MathUtil.radToDeg(Math.atan2(dy, dx));
+ util.target.setDirection(direction);
+ }
+
// This corresponds to snapToInteger in Scratch 2
limitPrecision (coordinate) {
const rounded = Math.round(coordinate);