Shooter: How to keep the player in position?

0 favourites
  • 3 posts
From the Asset Store
Players follower. use it for anything which follows the player
  • I'm doing a vertical scrolling shooter, I'm using the huge layout/ scroll to/ move scroller object with bullet method.

    I basically took this from the Space Blaster example. In this very same example the player sticks to the background i.e. if you don't move him, he will move gradually towards the lower end of the screen.

    To compensate this and to keep him in place like in every arcade shooter I add a value to the player's Y-position per tick, I use

    Player: Set Y to Player.Y - (Scroller.Bullet.Speed / 60)

    I had assumed the tick frequency to be 60, which seems to be correct.

    Now this whole contraption *sort of* works, but not 100% correctly. I get a periodic micro-jitter of ~1 pixel sometimes, which I assume is a rounding problem somewhere.

    So.... how to do this correctly (and keep it relative to the Bullet-speed of the Scroller object which I might need to alter the scrolling speed)?

    Others seem to have done it, the Project Blaze Zero shooter looks 100% in sync to me <img src="smileys/smiley5.gif" border="0" align="middle" />

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This probably isn't the solution to the problem, but you should use *dt instead of /60.

    dt stands for delta time and is the amount of time (in seconds) since the last tick... so it'll change with any frame rate dipping.

    Micro-jitter of 1 pixel makes me think of the 'pixel-rounding' project property. Other than that I'd suggest posting your capx

  • This probably isn't the solution to the problem, but you should use *dt instead of /60.

    In fact, it is..

    I was unaware of the dt-variable, using it fixed the jitter. So what I was seeing was basically the result of a small wobble in the framerate, not a rounding issue.

    Now everything is fine.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)