c# - can't get my for loop to work -


i'm having trouble getting loop work. can either work once, or without limit. i'm trying coins instantiate 3 times. don't think loop wrong, structure somewhere is. loop in looted function.

using system.collections; using system.collections.generic; using unityengine;  public class corpsekicked : monobehaviour {  private rigidbody2d rb; private animator anim; public gameobject coinprefab; public transform coinspawn; private bool kicked = false; public float timer = 2f; public gameobject deathflameprefab; private bool flamer; private bool pay = false; private bool broke = false;  void start () {     anim = getcomponent<animator> ();     rb = getcomponent<rigidbody2d> (); }  // update called once per frame void update () {     looted (); }  public void ontriggerenter2d(collider2d other) {     if (!kicked && other.gameobject.tag == "kickindicator") {         kicked = true;         transform.translate (0.0f, .05f, 0.0f);     } }  public void looted () {     if (!pay && kicked) {          pay = true;         instantiate (coinprefab, coinspawn.position, coinspawn.rotation);         kicked = false;         pay = false;         (int = 1; <= 3; i++)              debug.log ("$$$$$$$$$");     } } 

public gameobject deathflameprefab; private bool flamer; private bool pay = false; private bool broke = false; private int kickedcount = 0;  void start () {     anim = getcomponent<animator> ();     rb = getcomponent<rigidbody2d> (); }  // update called once per frame void update () {     looted (); }  public void ontriggerenter2d(collider2d other) {     if (!kicked && other.gameobject.tag == "kickindicator") {         kicked = true;         transform.translate (0.0f, .05f, 0.0f);     } }  public void looted () {     if (!pay && kicked) {          pay = true;          kicked = false;          if (kickedcount < 3)         {            instantiate (coinprefab, coinspawn.position, coinspawn.rotation);            kickedcount++;         }         pay = false;     } } 

am uncertain pay may need place within if statement


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -