Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by mimik

Trying to make a smooth camera in a topdown game.

Camera works fine as long as we have 60fps.
But if the game drops below we get a studdery camera.

Is there a way i missed to make it smooth or frame rate independent?

Camera code:


this.camspeed = 4 // same result with any number.

this.screen.x = this.screen.x - (this.screen.x - (this.player.pos.x - ig.system.width / 2)) * ig.system.tick * this.camspeed

this.screen.y = this.screen.y - (this.screen.y - (this.player.pos.y - ig.system.height / 2)) * ig.system.tick * this.camspeed

Also checked Dominics camera plugin but that doesn't work for top-down.

1 decade ago by Joncom

I used interpolation to "smooth" the camera transitions in this demo.

Is this sort of what you mean?

1 decade ago by mimik

Don't think that a tween will work when the player change position every frame.
Wouldn't that just trigger a new tween every frame/as soon as the tween ends.
Making the camera more sloppy.

This current camera work fine on desktop but fails hard on lower devices like the ipad/iPhone

1 decade ago by Joncom

Please define what "smooth camera in a topdown game" means.

I'm not sure what your code is supposed to do.

If you just want the camera to follow the player, this is more simple/effective:

this.screen.x = this.player.pos.x - ig.system.width / 2 + this.player.size.x / 2;
this.screen.y = this.player.pos.y - ig.system.height / 2 + this.player.size.y / 2;

1 decade ago by mimik

a chase camera, using learping. so the camera follows but with a delay
top down camera.

1 decade ago by mimik

the above code its just like this camera with interpolation.
http://www.ludumdare.com/compo/2014/01/02/2d-camera-issues-resolved/

but at lower frame-rates there is a studder and hackyness.

will try your interpolation thingy now seams like a good idea

1 decade ago by mimik

tested a couple of different camera systems they all work fine but if there is frame-rate drops naturally there will be a camera glitch.

Simply changed the camera to a static one on lowend devices.
Thanks anyway Joncom the interpolation solution was nice as well.
Page 1 of 1
« first « previous next › last »