Highlighted

Creating a counter using expressions and keyframes (such as kills in a game)

New Here ,
Oct 12, 2020

Copy link to clipboard

Copied

Hello, I hope you can help! 

 

I own a YouTube channel that entertains through the counting of kills in single player video games.  

 

Currently, I change each kill by updating a title card where each kill occurs (1,2,3,4,5,etc) and soemtimes these games can have well over thousands of kills which takes me days and even weeks to edit.  I also use a kill sound to notify of each kill as the counter increases.

 

So my two part question is;

 

1)  Would I be able to use a more efficient manner of counting kills through using keyframes to count exactly the moment I need it to?

 

Currently this expression (thisComp.layer("Null 1").transform.position.nearestKey(time).index) increases the counter when the timeline is in the middle of two keyframes, and not directly on the next keyframe. and 

 

2)  Can I link a trigger to play a sound sample each time the keyframe is activated?

 

For reference, here is my latest video that took 7 full days to create and is the effect I want to achieve through any other efficient means; https://youtu.be/ICUYMXfR7Is

 

I look forward to hearing from you, any assistance or advice is greatly appreciated. 

Kill Count - All kills made by the player. ABOUT THIS GAME You are Gordon Freeman, a theoretical physicist at the Black Mesa Research Facility. When a routin...
TOPICS
Expressions, How to, Scripting

Views

29

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Creating a counter using expressions and keyframes (such as kills in a game)

New Here ,
Oct 12, 2020

Copy link to clipboard

Copied

Hello, I hope you can help! 

 

I own a YouTube channel that entertains through the counting of kills in single player video games.  

 

Currently, I change each kill by updating a title card where each kill occurs (1,2,3,4,5,etc) and soemtimes these games can have well over thousands of kills which takes me days and even weeks to edit.  I also use a kill sound to notify of each kill as the counter increases.

 

So my two part question is;

 

1)  Would I be able to use a more efficient manner of counting kills through using keyframes to count exactly the moment I need it to?

 

Currently this expression (thisComp.layer("Null 1").transform.position.nearestKey(time).index) increases the counter when the timeline is in the middle of two keyframes, and not directly on the next keyframe. and 

 

2)  Can I link a trigger to play a sound sample each time the keyframe is activated?

 

For reference, here is my latest video that took 7 full days to create and is the effect I want to achieve through any other efficient means; https://youtu.be/ICUYMXfR7Is

 

I look forward to hearing from you, any assistance or advice is greatly appreciated. 

Kill Count - All kills made by the player. ABOUT THIS GAME You are Gordon Freeman, a theoretical physicist at the Black Mesa Research Facility. When a routin...
TOPICS
Expressions, How to, Scripting

Views

30

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Oct 12, 2020 0
New Here ,
Oct 12, 2020

Copy link to clipboard

Copied

Rick Gerard, thank you for the answer in reponse elsewhere! 

 

From Rick; 

You can retrieve the time of the nearest keyframe or the number of the nearest keyframe by starting with this simple expression:

ref = thisComp.layer("Reference Layer");
keyTime = ref.position.nearestKey(time).time;
keyIndex = ref.position.nearestKey(time).index;

In this case, I'm looking at the Position property of a layer named "Reference Layer" and returning the keyframe time and the keyframe number. 

 

You can then use if/else statements, accumulators, or other methods to make changes to other properties.

 

You cannot cue audio tracks using keyframes but you could time remap an audio layer, extend it. set a couple of keyframes at the start and end of a sound effect, then use an if statement to start playing the sound when a new keyframe is reached. This would be the same kind of thing you would use to drive time remapped mouth shapes to animate a character.

 

I don't have time to figure out all of the code for you but if you are good with Expressions and do a little research, you should be able to make something happen when you get to a keyframe on another property.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0
Adobe Community Professional ,
Oct 12, 2020

Copy link to clipboard

Copied

If you record audio with your screen capture and you can filter out the sound you want to use then you can use Convert Audio to Keyframes to generate keyframes for the game audio and just set a minimum value for your expression.

 

If you have keyframes already set that you want to count this is all you need:

ref = thisComp.layer("Reference Layer").position;
keyTime = ref.nearestKey(time);

if (keyTime.time <= time)
	keyNumber = keyTime.index;
else
	keyNumber = keyTime.index - 1;

The keyframe count would start at 1.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Oct 12, 2020 0