list misbehaving in bubble shooter
Hello guys i am making a bubble shooter replica ,i am very new to unity(just 1 month).and a made a code to manage different aspects of the game.in my gamemanager script i have made a list of all those bubbles that have collided with playerbubble,the problem that i ma facing is my list not empty in the start and my variables are also misbehaving .although my int fla is zero in the beginning but still if statement is not getting executed. pls help and sorry for bad english and way of writing.and thanks in advance.
using UnityEngine; using System.Collections.Generic; public class gameman : MonoBehaviour {
int invocalled;
int fla=0;
List<GameObject> colmapbubble;
GameObject playerbub;
public void collisionDetectr(GameObject CmapBub)
{
Debug.Log("flag:" + fla);
fla = 0;
Debug.Log("flag:" + fla);
**if (fla == 0)**
{
colmapbubble.Clear();
invocalled = 1;
fla = 1;
}
Debug.Log("invke called value= "+invocalled+" count: "+colmapbubble.Count);
colmapbubble.Add(CmapBub);
if(invocalled == 1)
{
Invoke("afterAllcollision", 0.1f);
invocalled = 5;
}
}
public void initPlayerbub(GameObject temp)
{
playerbub = temp;
}
void afterAllcollision()
{
for(int i=0;i<colmapbubble.Count;i++) //clearing llistvisited
colmapbubble[i].GetComponent<llist>().llistvisited = false;
colmapbubble.Clear(); //clearing list
playerbub.GetComponent<Rigidbody2D>().isKinematic = true; //enabling kinematic
playerbub.tag = "mapBubble"; //changing tags
playerbub.GetComponent<playerBubblemovement>().enabled=false;
GetComponent<traverseGrid>().StartTraversing(playerbub); //traversing grid
GetComponent<createPlayerbubble>().createnewPlayerbubble(); //create new playerbubble
invocalled = 1; //this function can now be invoked again
fla = 0;
}
}
Your answer

Follow this Question
Related Questions
Objects, GameObjects, Lists, and lists of GameObjects with Objects, oh my! 2 Answers
How to create a list in a specific order of one script that is used in different gameobjects? 0 Answers
Match Level 2 With Level 2 questions and answers? 1 Answer
How do I adjust code so gyro translates player to center position when device is being held in hands 1 Answer
error CS0103: The name `collidedwith' does not exist in the current context 1 Answer