ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Selection which objected will show.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
George Felix
Selection which objected will show.
on Jul 17, 2017 at 9:46:19 am

I have this project that I am working on and I need an idea on how to implement it.

I am writing a soccer template and I need to place the player’s photo and names on the field positions that they are playing.

Each player will have his own composition, that will hold all of his information. I will have to make the soccer field a 3d object where the player composition will be at an angle. Up to this point it is OK. I can do this NO problem. The problem lies with placing the player in the proper position of the field.

All the soccer templates out on the market have the setup of 4 – 4 – 2. That is 4 in defense, 4 in midrange and 2 forwards. If you want to have a 1 – 3 – 3 – 1 – 2, you will have to make up your own template. If figured that if I have 9 rows and each row will have 5 columns, I could show any possible combination of the players on the field.

So think of it as a table with 45 cells, where each cell will be represented with a variable. If the variable has a value, then its composition will have an opacity of 100% otherwise it will be 0%.

My question is how do I check to see if a variable has a value in it or is empty. Is there a command for this? If it is empty, I don’t want it to give me an error.


George


Return to posts index

Scott McGee
Re: Selection which objected will show.
on Jul 17, 2017 at 12:17:11 pm

I would do something on these lines.

Create a text layer, copy and paste in your 1 – 3 – 3 – 1 – 2

If it was 5x5 for example.

You'd in your opacity of each Item.

Say it's row 2 I'd put the following expressions like so.

column 1
I = parseInt(thisComp.layer("Text").text.sourceText.split("-")[1])
if (I >= 4) {100}
else {0}

column 2
I = parseInt(thisComp.layer("Text").text.sourceText.split("-")[1])
if (I >= 2) {100}
else {0}

column 3
I = parseInt(thisComp.layer("Text").text.sourceText.split("-")[1])
if (I == 1 | I >= 3) {100}
else {0}

column 4
I = parseInt(thisComp.layer("Text").text.sourceText.split("-")[1])
if (I >= 2) {100}
else {0}

column 5
I = parseInt(thisComp.layer("Text").text.sourceText.split("-")[1])
if (I == 5) {100}
else {0}


Then if you want to centralise on if it's 4, I'd add an expression on the position layer like this or to a null and attach 1-4 to that.

I = parseInt(thisComp.layer("Text").text.sourceText.split("-")[1])
if (I == 4) xPos = 995
else xPos = 915;

[xPos,540]


(Obviously change values to your preference)

There are some methods where you could make this easier using thisComp.layer(index+1).name, put a text layer at the bottom of them label it 2 (For row 2)

a = thisLayer.name - 1;
thisComp.layer("Text").text.sourceText.split("-")[a];

Paste this into source text, this will then use the layers name for which row you want.

Then use the above expressions still for the columns but in order

column 1
I = parseInt(thisComp.layer(index+1).text.sourceText)

column 2
I = parseInt(thisComp.layer(index+2).text.sourceText)

etc

So when you duplicate, drag them above our example of row 2, 2 should label itself as 3...Then the others should correspond. Obviously you'll have to alter positions, but if you use a similar method to attach to null (Label it in a similar method and use the index aswell), you shouldn't have to do much hard work.

Sorry for all the waffle, I can't think of an easier way to explain it without sending you a built version, but I use this in building my weather projects. I had 8 to build with 8 cities, with a morning, afternoon and evening section. then also make a presenter version and a none presenter version. So this method saved me weeks worth of work. But also I can change stuff with ease and not have to rewrite my expressions.

You also can use a time remapping aswell if you are putting numbers on jerseys, then use an expression to know which jersey to use in which of the columns, but my lunch hour is over, so if you want any help with that, happy to give you that expression later.


Return to posts index

George Felix
Re: Selection which objected will show.
on Jul 18, 2017 at 8:00:06 am

Thank you, but I was looking something more general to have.

Basically I'm looking for a command that would test if a variable exists or not. If it is defined or undefined. Each variable will corresponds to a specific location on the field. If it exists, then its composition’s opacity will be 100% and will show. If the variable does not exists, then the composition’s opacity will be 0%


One way of doing this is in my data file (text file) in the first lines I would zero out, all of the variables. Later on I could the ones that correspond to the players position a value. I would then do a test to see if the value is zero on not, but really don’t want to go that way.

Thank you
George


Return to posts index


Scott McGee
Re: Selection which objected will show.
on Jul 18, 2017 at 8:28:58 am

I understand what you mean, but I don't know a simpler way of accomplishing that.

I did something similar with constituency maps, when a station typed in their station and constituency. It would turn it 100% and put it into the designated position. If it wasn't defined it would be 0% and hang off the board, but that's no different than what I offered above.

I built a weather project, that is updated twice a day and I have 8 stations 8 location per station to update. That include weather icons, temperature, windspeed, wind direction. with a 5 day forecast at the end. This is a massive project, using a data file like you've suggested using. It's took 3 weeks to build, but it's flawless when the data is updated.

If someone can offer a simpler solution, I'll keep my eyes peeled to this post, because I'm always trying to shave time off my builds to create templates faster, but based off the research I had to do to get the weather project built. I think the above might be your only option.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]