- Home /
Question by
mmyoonsin94 · Mar 13, 2018 at 06:21 PM ·
unity 5vuforiaupdate functionincrementstudent
How increment only once in function Update
void Update()
{
currentRubbish = rubbish[currentY][currentX];
Debug.Log("Name tag of current rubbish:" + currentRubbish.tag);
rubbishScreen = arCamera.WorldToScreenPoint(currentRubbish.transform.position);
//Get the Vuforia StateManager
StateManager sm = TrackerManager.Instance.GetStateManager();
IEnumerable<TrackableBehaviour> currentTrackables = sm.GetActiveTrackableBehaviours();
//Iterate through the list of active trackables
foreach (TrackableBehaviour cT in currentTrackables)
{
binScreen = arCamera.WorldToScreenPoint(cT.transform.position);
if (cT.TrackableName == currentRubbish.tag)
{
Debug.Log("Trackable matched:" + currentRubbish.tag);
Debug.Log("Rubbish ScreenPosition===" + rubbishScreen.y);
currentRubbish.transform.Translate(Vector3.down * 100f * 1 * Time.deltaTime);
if (rubbishScreen.y - binScreen.y < 60)
{
currentRubbish.SetActive(false);
////HERE need help
currentX = currentX + 1;
currentRubbish.SetActive(true);
}
}
else
{
Debug.Log("Not match!");
}
}
}
Currently, I have code inside void Update function. There is increment inside this function, can it be incremented +1 only once instead of loop all of it. And then self run again the code inside the void Update.
I have wrote a function before that applied with onclick, when I call or click the function once, the increment happens only once.
But now the increment in void Update is keep looping. Any idea on how to solve it? Thank you.
Comment
Your answer
Follow this Question
Related Questions
Random get element from a jagged array 1 Answer
Failed to load QCARWrapper.dll 0 Answers
WWW object it's not retrieving bundle Aset 0 Answers
Extended tracking in unity using vuforia model target? 2 Answers