I have tried repeatedly to post this but it kept failing to post. It could be due to the zip file attachment, even though it is only 2.5MB. So I will post this text, and try to post the zip file as a second post.Raxx's script isn't as easy as it could be to use. So I have refactored it to make it as simple to use as I can. There is no time scaling in this version of the script.
I have attached a zip file containing an example project with two flames. Only absolute paths work, so for this example project to work on everyone's machine, it needs to be in a known location. I've coded the scripts to work if you un-zip the attached zip file to the directory:
C:\Simple Animated Texturesi.e.
The flame .png files should be located in the directory:
C:\Simple Animated Textures\Sprites\fireTo correspond to the path set with the script line:
$texPath = "C:/Simple Animated Textures/Sprites/fire/";(Relative paths can appear to work when you scroll along the time line, but render movie will not be animated.)
To run the example project:
In Anim8or open "C:\Simple Animated Textures\Example 1 - Two flames.an8"
Switch to Scene view.
Select camera view (e.g. press 1 on the numeric key pad)
The flames will animate if you drag the time slider, or render the movie.
This is the video it renders:
This is a much simplified version of Raxx,s script which bypasses most of the complexity.
I use the
frame variable to work out which texture file needs to be loaded - so no messing around with graphs or keys.
To use the script for youself you just have to:
1) Create a named texture. For example the left hand flame texture in the example is named "fire1". And the script you create for this texture in step 2e knows which texture to animate with the following line:
$t = project.LookupTexture("fire1");Raxx's video:
&t=5s&ab_channel=Raxx
walks you through creating this texture at 2:01, and applying it to a mesh between 1:04 and 3:23
Raxx's video gives a second example of doing this between 4:09 and 5:18
2) for that texture, in Scene view:
a) add a Target (Build->add target). Give it a name like "fire3_sprite" to aid you knowing which texture it corresponds to.
b) double click on the target, and click on the "..." in the "Location" section.
c) make sure the "On" Expression radio button is selected, and press "Edit" next to it.
d) Open "C:\Simple Animated Textures\sprite_controller.txt" in a text editor, select all the text and copy it. Then replace the text in the Script Viewer that was displayed as a result of pressing "Edit", by pasting the text from "sprite_controller.txt"
e) Tweak the script to match your needs. E.g. the absolute path to the texture animation files. And the name of the texture that this script corresponds to. And the number of the first and last file in the animation sequence. To change which texture frame is displayed on a particular animation frame set the
$firstFrameNum variable.
f) Press OK, on each of the three pop-up windows to close them down. Then save your project.
3) The texture should animate now. Presuming you have applied it to a mesh (I applied the texture to both Ambient and Diffuse in the example project).
I've posted a superman video to YouTube using it:
Other notes (Things that I may have over simplified):
1) One of the simplifications I have made is to remove the variables to disable the script. But you can disable the script by commenting out the entire script. You can do this by placing a "/*" open comment before the first line, and a matching "*/" after the last line to disable the script. (The speech marks are not to be included.)
2) To keep the time line clean, it makes sense to place the sprites under a parent object like Raxx does. In his video he shows how to create a container object to contain scripts at 15:54 :
Build->Add Target
Name it: sprites_scripts
Then double click on the individual sprites, like "fire1_sprite", and select "sprites_scripts" as the parent.
3) The simplified script loops over the texture files for the entire period of animation. However it would not be hard to modify the script to have a lead-in texture file to be displayed before
frame == $firstFrameNum. e.g. this could be a png with all pixels 100% transparent. And you could have another file to be displayed when
frame > ($firstFrameNum + $numFrames). E.g. a soot mark from an explosion.
This is a bit more advanced, and you will be changing code that appears after the line:
// /////////////////////////////////
// EVERYTHING PAST HERE, LEAVE ALONE
// /////////////////////////////////