Follow on X

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

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

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.

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

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.