# How would I make the camera only follow mySprite horizontally?

**URL:** <https://forum.makecode.com/t/how-would-i-make-the-camera-only-follow-mysprite-horizontally/18495>\
**Category:** Help\
**Tags:** game\
**Created:** [March 18, 2023, 1:47am UTC](https://forum.makecode.com/t/how-would-i-make-the-camera-only-follow-mysprite-horizontally/18495 "2023-03-18T01:47:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pikaahhh](https://avatars.discourse-cdn.com/v4/letter/p/f9ae1b/32.png) [@Pikaahhh](https://forum.makecode.com/u/Pikaahhh)\
**Post date:** [March 18, 2023, 1:47am UTC](https://forum.makecode.com/t/how-would-i-make-the-camera-only-follow-mysprite-horizontally/18495/1 "2023-03-18T01:47:56Z")

</div>

> **[Super Mario Custom](https://arcade.makecode.com/99893-49718-04312-95185)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

If you have a solution, that would be cool!

---

<div class="post-metadata">

**Author:** ![randomuser](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/randomuser/32/32505_2.png) [@randomuser](https://forum.makecode.com/u/randomuser)\
**Post date:** [March 18, 2023, 3:21am UTC](https://forum.makecode.com/t/how-would-i-make-the-camera-only-follow-mysprite-horizontally/18495/2 "2023-03-18T03:21:53Z")

</div>

You could set the camera X to the sprite X!

---

<div class="post-metadata">

**Author:** ![felixtsu](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/felixtsu/32/12024_2.png) [@felixtsu](https://forum.makecode.com/u/felixtsu)\
**Post date:** [March 18, 2023, 3:23am UTC](https://forum.makecode.com/t/how-would-i-make-the-camera-only-follow-mysprite-horizontally/18495/3 "2023-03-18T03:23:44Z")

</div>

forever  
center camera at x mySprite.x y 60 ( any fixed number)

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/5/5695eb7f3bec81eceb346ca0ef9095bc7c524321.png)

> **[Super Mario Custom](https://arcade.makecode.com/S56210-12134-16473-87780)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Pikaahhh](https://avatars.discourse-cdn.com/v4/letter/p/f9ae1b/32.png) [@Pikaahhh](https://forum.makecode.com/u/Pikaahhh)\
**Post date:** [March 19, 2023, 10:18pm UTC](https://forum.makecode.com/t/how-would-i-make-the-camera-only-follow-mysprite-horizontally/18495/4 "2023-03-19T22:18:20Z")

</div>

It’s very choppy though.

---

<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:** [March 19, 2023, 10:24pm UTC](https://forum.makecode.com/t/how-would-i-make-the-camera-only-follow-mysprite-horizontally/18495/5 "2023-03-19T22:24:19Z")

</div>

This is a scenario where on game update would work better actually:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/ff2486d9a489c758004b080b0a54cdf9a1936e4f.png)

reason being that forever spins up a separate thread to run the code in, so it will always be ‘1 render’ behind / potentially could miss a frame depending on timing a bit; since this is code we want to update synchronously it’s better to update it with on game update where it will always start and finish before we actually render to the screen (a little bit of documentation on this for anyone interested here: [https://arcade.makecode.com/developer/game-loop](https://arcade.makecode.com/developer/game-loop))

Alternatively, we use my sprite utils extension ([https://github.com/jwunderl/arcade-sprite-util](https://github.com/jwunderl/arcade-sprite-util)) which has a block to run at certain parts in the game loop if you care about the exact timing when something should run, but on game update should generally handle these types of things well  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/f/f8327a1e3b64477b637ea3301ef0b1ffa78c9996.png)
