complete code in an if-statement even if statement turn false
The current problem right now is I have a movement function, specifically Vector2.Lerp(), inside an if statement. What I want to happen is if the if-statement is true, the Lerp should activate and finish. But before the Lerp activates, I need to make the conditions in the if-statement false and still have the Lerp complete, how would I do that? Right now it stops because the if statement turns false.
Answer by mjboga29 · Nov 09, 2018 at 02:39 AM
In the code, after the Lerp activates, put in "WaitForSeconds(1f)" that should give time for it to activate, and after one second the code will continue and then the if statement will be false. Im not 100% sure if this will work but you can try. Sry if it didnt help
This won't make the Lerp continue if I make the condition that the Lerp is in false. Thanks for the answer though.
Answer by Nivbot · Nov 09, 2018 at 03:21 AM
If (originalBool || lerpBool)
{
oringinalBool == false;
vector3.Lerp(blah blah);
If(whatever makes lerp stop)
{
lerpBool == false;
}
}
Im sorry, but what do you mean by "whatever makes Lerp stop"?
I also do not think this will work. i need to able to interrupt the if statement mid Lerp.
What I meant by whatever makes the lerp stop is just that. Did it reach the destination or did something happen that you want to stop it. The way it is written allows you to set the original bool to false and allows you and continue the lerp if that's what you wanted to do.
Or, you can always just separate them If(OriginalBool == true) { OriginalBool = false; lerpBool = true; } if(lerpBool == true) { //do lerp stuff here }
Otherwise I'm not sure what you are really trying to do
Your answer
![](https://koobas.hobune.stream/wayback/20220612181804im_/https://answers.unity.com/themes/thub/images/avi.jpg)