-
If / Else with No Else?
I’m just barely learning and this is probably a bit basic but I’d appreciate any help.
I am trying to put a couple conditions on the same expression. It works great except for one problem. My code works like this:
if
(various conditions are met)
12else
if
(other conditions)
1else
5
You’ll notice the “else 5” at the bottom… that’s the problem. I DON’T actually want a final “else.” If none of the conditions are met, I’d like the value to just stay wherever it was last. However, without a final “else… something” it will insist on reverting to zero when nothing is met.
How can I get it to just hold the last value?
I feel like it must be possible, because if I have only the first part:
if
(various conditions are met)
12It works the way I’d want. But once I add the second (even if I forgo the else syntax) it doesn’t allow that.
I put the actual code below if you need more detail… it’s basically a simple collision detector. But I don’t want the value to revert when the collision is over. I want it to stay until the pointer runs into a new object.
So basically I’d just like the else to do nothing at all.
t=100if
(thisComp.layer("pointer thing").transform.xPosition <= thisComp.layer("A12").transform.xPosition + t && thisComp.layer("pointer thing").transform.xPosition >= thisComp.layer("A12").transform.xPosition - t && thisComp.layer("pointer thing").transform.yPosition <= thisComp.layer("A12").transform.yPosition + t && thisComp.layer("pointer thing").transform.yPosition >= thisComp.layer("A12").transform.yPosition - t)
12else
if
(thisComp.layer("pointer thing").transform.xPosition <= thisComp.layer("A11").transform.xPosition + t && thisComp.layer("pointer thing").transform.xPosition >= thisComp.layer("A11").transform.xPosition - t && thisComp.layer("pointer thing").transform.yPosition <= thisComp.layer("A11").transform.yPosition + t && thisComp.layer("pointer thing").transform.yPosition >= thisComp.layer("A11").transform.yPosition - t)
11
else
5