# Follow on X

**URL:** <https://forum.makecode.com/t/follow-on-x/2729>\
**Category:** Help\
**Created:** [July 10, 2020, 5:00pm UTC](https://forum.makecode.com/t/follow-on-x/2729 "2020-07-10T17:00:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![GameGod](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/gamegod/32/2756_2.png) [@GameGod](https://forum.makecode.com/u/GameGod)\
**Post date:** [July 10, 2020, 5:00pm UTC](https://forum.makecode.com/t/follow-on-x/2729/1 "2020-07-10T17:00:39Z")

</div>

How can I make a sprite follow another sprite, but only horizontally?

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [July 10, 2020, 5:29pm UTC](https://forum.makecode.com/t/follow-on-x/2729/2 "2020-07-10T17:29:27Z")

</div>

Not possible with the current follow behavior, I’m afraid. I don’t think it’s a bad idea though… What do you think @jwunderl

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [July 10, 2020, 5:38pm UTC](https://forum.makecode.com/t/follow-on-x/2729/3 "2020-07-10T17:38:51Z")

</div>

The way I wrote the sprite follow isn’t particularly extensible that way; it was written more for efficiency / to allow lots of sprites to follow at once without hurting perf, and would likely take a big hit if we made it so follow vx / vy were separately configurable.

That said, it’d be very easy to add a flag like 'follow direction {both|horizontal|vertical}` hidden behind a plus if we want, and just have it branch off to a simpler calculation for horizontal / vertical.

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [July 10, 2020, 5:40pm UTC](https://forum.makecode.com/t/follow-on-x/2729/4 "2020-07-10T17:40:16Z")

</div>

I’m trying to think of scenarios… It’s _really_ nice for pong, also SHMUP games

---

<div class="post-metadata">

**Author:** ![jwunderl](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/jwunderl/32/5308_2.png) [@jwunderl](https://forum.makecode.com/u/jwunderl)\
**Post date:** [July 10, 2020, 5:52pm UTC](https://forum.makecode.com/t/follow-on-x/2729/5 "2020-07-10T17:52:17Z")

</div>

Hm… are there cases you can think of where you would want to follow in different (non-zero) speeds per direction?

I guess worst case, could use the flags approach and just allow someone to set both vertical and horizontal follow on the same sprite independently, just make sure they don’t conflict - a little bit slower, but wouldn’t matter for most cases?

I’ll try playing around with it, might be able to rewrite it a bit and separate the speeds without a big perf hit; it might be easier than I’m thinking, I don’t remember if I looked into doing that after I last cleaned it up.
