Search Unity

Move ball at constant speed on screen

Discussion in '2D' started by siddharth3322, Apr 21, 2015.

  1. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    I want to move ball constantly on screen as per my question title suggest at fixed speed. If your suggestion is using physics based movement then it is advantage for me.

    Basically I am working on following game :


    If you suggest me any link or tutorial for this then also it is okay, I will go over through that also. Please give your suggestion.
     
  2. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Here You have whole tutorial about making that kind of game: link.
    Tip. Simply Uncheck IsGravity in Your ball. Then add initial AddForce like in tutorial above.
     
    Last edited: Apr 21, 2015
  3. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    @codeedward , Thanks for your reply. I have watched that full video but in that there are some situation that I don't want in my game. I want fixed speed ball movement on each time of game play.

    Using above approach some time ball move with faster speed and some time ball movement become too much slow.
    Please give some other opinion for this task.
     
  4. codeedward

    codeedward

    Joined:
    Dec 19, 2014
    Posts:
    93
    Did You set bounciness to '1'? Watch this wideo from 18th minute and notice that Bouncy material is that what You need in all Your objects to Your ball do not lose speed. This is only one thing that make this ball slower I think. Remember also to turn off ball Gravity (IsGravity property). So basically You need to remove all other forces that act on Your ball.

    This is solution IMO is good for this game. On the other hand if You want to do this is other way You could just update ball velocity in every frame :p