i need help for this loop .i making 2D pipe puzzle game. so for that i need one true value if all the objects are set in correct direction . which is this condition If (All objects return true){ you win} .
i need function where its excutes if all objects are in correct direction.
Answer by MagnaDever · Jun 05, 2018 at 06:59 AM
Create array of elements, and in element prefab create variable "correct". Then in loop check correct value.
public bool IsCorrect()
{
for(int i = 0; i < elems.Length;i++)
{
if(!elems[i].correct)
{
return false;
}
}
return true;
}
its returning true for every objects returning true; so i need if all value return true then he should win. i have kept IsCorrect inside Update function. void update(){ if(isCorrect){ print("You win"); } }
You're mistake. If any element will be not correct, it's return false. And not update. You must call this function when any element change direction
THAN$$anonymous$$S BUDDY. YOU ARE SO SO $$anonymous$$UCH GREAT.THIS IS JUST GREAT.
Your answer
Follow this Question
Related Questions
How do i make part of an object disappear both in rendering and collision with triggers? 1 Answer
3D effects on 2D objects 0 Answers
Avoid changes if I dont changing my position. 1 Answer
2D side scroller shoot at mouse click 0 Answers
Sprites in Sprite Editor turn Invisible and cannot be sliced 0 Answers