# Script written by SuperFromND. C00. Do whatever you want!
# Written for Blender 4.2.3 LTS, but should work in older versions just fine.
# This script takes the selected objects (assumed to be image planes stacked on top of eachother)
# and generates keyframe data such that each object will "animate" by being scaled up and down
# for a set duration in sequence. This effectively emulates an image sequence/animation.
# This script was designed mainly for stage creators and 3D modelling work for the Ikemen GO fighting game engine.
# This is because we use the glTF format, which doesn't support animated textures of any kind.
# ==================================================================================================================
# SETTINGS START HERE
# Change this number to set the duration of every frame.
# The framerate is tied to whatever the Blender project's framerate is; by default, 24 FPS.
frame_length = 1
# SETTINGS END HERE; the rest is program code. Don't touch unless you know what you're doing!
# ==================================================================================================================
import bpy
frame_start = 0
animation_length = frame_length * len(bpy.context.selected_objects)
scale_off = (0.0, 0.0, 1.0)
scale_on = (1.0, 1.0, 1.0)
for obj in bpy.context.selected_objects:
frame_end = frame_start + frame_length
# Hides the object at the start of the animation
# Ensures a proper cyclic loop point
if frame_start != 0:
obj.scale = scale_off
obj.keyframe_insert(data_path="scale", frame=0)
# Shows the object
obj.scale = scale_on
obj.keyframe_insert(data_path="scale", frame=frame_start)
# Hides the object
obj.scale = scale_off
obj.keyframe_insert(data_path="scale", frame=frame_end)
# Similar to above, but for the end point
if frame_end != animation_length:
obj.scale = scale_off
obj.keyframe_insert(data_path="scale", frame=animation_length)
# Oh, and for the first object, show it on the end of animation too
# This just prevents loop flickering
if frame_start == 0:
obj.scale = scale_on
obj.keyframe_insert(data_path="scale", frame=animation_length)
# Sets animation curves to CONSTANT and enables cyclic curves
fcurves = obj.animation_data.action.fcurves
for fcurve in fcurves:
c = fcurve.modifiers.new('CYCLES')
fcurve.extrapolation = 'CONSTANT'
for kf in fcurve.keyframe_points:
kf.interpolation = 'CONSTANT'
# Increment frame start
frame_start += frame_length