Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2D Endless Runner

Discussion in '2D' started by namlunoy, Aug 28, 2015.

  1. namlunoy

    namlunoy

    Joined:
    Apr 15, 2014
    Posts:
    32
    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?
     
  2. Outwizard

    Outwizard

    Joined:
    Jun 25, 2015
    Posts:
    22
    namlunoy likes this.
  3. Rostam24

    Rostam24

    Joined:
    Mar 5, 2014
    Posts:
    119
    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 :)
     
    namlunoy likes this.
  4. namlunoy

    namlunoy

    Joined:
    Apr 15, 2014
    Posts:
    32
    Thank you, I'll try it!
    But I think it's not help much, because I use just a few Debug.Logs!
     
  5. namlunoy

    namlunoy

    Joined:
    Apr 15, 2014
    Posts:
    32
  6. Outwizard

    Outwizard

    Joined:
    Jun 25, 2015
    Posts:
    22
    Yes.
     
  7. Outwizard

    Outwizard

    Joined:
    Jun 25, 2015
    Posts:
    22
    If you use just a few, but every frame, it will cause hickups.
     
  8. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    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.
     
  9. namlunoy

    namlunoy

    Joined:
    Apr 15, 2014
    Posts:
    32
    I don't call Debug in update just in a few callback methods!
     
  10. namlunoy

    namlunoy

    Joined:
    Apr 15, 2014
    Posts:
    32
    I move things in update too!
    But, In your game you move the player or move the others?
     
  11. tedthebug

    tedthebug

    Joined:
    May 6, 2015
    Posts:
    2,570
    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.