2D Endless Runner

I’m trying to make a Endless Runner game!
My solution is make player stand and move the obstacles move!
I attack Riggidbody2D and BoxCollider for them and move by change velocity!
When i buid to mobile, it’s not quite smooth, still lags and hiccups !
I have applied Object Pooling technique!

Do you have any ideal to help me?

If you are using physics it’s usually better to move the player and not everything else around him. Then you are moving just one thing…

Bear Boom
iOS:https://itunes.apple.com/us/app/id985992564?mt=8
Android:https://play.google.com/store/apps/details?id=com.Airbear.Airbear

1 Like

Probably not the case, but I’ll mention it anyway: when I was working on an endless runner, I also had performance issues (hickups). In my case it was caused by my debug.log calls… When I removed them, it ran 100% smooth :slight_smile:

1 Like

Thank you, I’ll try it!
But I think it’s not help much, because I use just a few Debug.Logs!

In your game you move the bear, right?

Yes.

If you use just a few, but every frame, it will cause hickups.

Is it being done in update or fixed update? I had issues similar because I had movement in fixed update & other non movement stuff in update. When I moved everything into update & got rid of fixed update it smoothed out.

I don’t call Debug in update just in a few callback methods!

I move things in update too!
But, In your game you move the player or move the others?

Each object had its own movement script which I put into update & removed from fixed update. That stopped them jitteriness a bit. I then did the same to the player & that fixed it.

In the end each object had its own update for their movement & the player had its own update for all of its movement. I had nothing left in fixed update. Mine wasn’t an endless runner though but it did involve every object needing physics so it could fall & be pushed properly when needed.

Unless you need physics for all of the objects you could remove the rigid bodies from them so only the player has one. Both at means less physics processing.