0
\$\begingroup\$

I've started making a game in AppGameKit and I'm using Tier 1/AGK2 Basic. I'm trying to make a sort of endless runner. I've made it so that the player stays still and the rest of the world moves around them to create the illusion that the player is what is running forward. I then use a global variable to control all movement relative to the player.

There must be a better way to do this, though. Like if I were to attach a camera to my player character. How would I do something like that?

\$\endgroup\$
1
  • \$\begingroup\$ What's wrong with this method? In the end, either moving the camera or moving the world end up with the same thing. I would do whichever is easiest \$\endgroup\$
    – CobaltHex
    Oct 12 '17 at 15:28
0
\$\begingroup\$

A 2D or a 3D game?

I would not move the world: it's messy. You would not only have to move the scene, but also the non player objects in it.

Instead I would move the player.

Every frame, I would update the camera so that it is always behind the player.

Looking at AppGameKit, it has a method SetCameraPosition() and SetCameraLookAt().

Just get the player object's position and direction it is facing. Then place the camera a certain distance behind, above, and optionally left/right of the player. And point the camera at it.

You can link the camera hard, this way. Or add a little softening in it by blending the desired and current camera position so that it will lag a little when player starts running faster.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .