c# - Accelerate ball over time -


i have ball need accelerate during time, give little force. tried accelerate time.deltatime divided specific values doesn't work.

this sample of code (to start game, need 1 tap , ball moving constant speed) , question how can automatically accelerating ball during time.

void start ()  {        application.targetframerate = 60;     gamestart = false;  }  void update () {     if (!gamestart)      {         if (input.touchcount >= 1)          {             gamestart = true;             getcomponent<rigidbody2d> ().addforce (new vector2 (1f, 0.5f) * force);           }     } } 

you can try this, have not changed variable names maintain familiarity original code

rigidbody2d myrigidbody void awake(){ myrigidbody = getcomponent<rigidbody2d>(); }  void start ()  {        application.targetframerate = 60;     gamestart = false;      // invokes method setgamestarttofalse in 2 seconds, repeatedly every 1 seconds.     invokerepeating("setgamestarttofalse", 2f, 1.0f); }  void fixedupdate () {     if (!gamestart)      {         if (input.touchcount >= 1)          {             gamestart = true;             myrigidbody.addforce(new vector2 (1f, 0.5f) * force);         }     } }  void setgamestarttofalse() {     gamestart = false; } 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -