Entity Texture Animations
Whats on this page?
From this page you will learn how to make an animated texture for an entity. Animated, like a flipbook texture for blocks.
Source
This page is based on content by AgentMindStorm.
Textures
First let's draw some new texture frames for our entity. In this tutorial it will be a cow, which is looking around.
We need to place our textures vertically, like for blocks in flipbook textures. In this case we have 4 frames.
Materials
We will need to modify materials in this guide. However due to render dragon materials became outdated, so use it at your own risk.
To use animated texture, we need to change the entity material to one, that has USE_UV_ANIM
property. Let's simply add a new material:
{
"materials": {
"version": "1.0.0",
"custom_animated:entity": {
"+defines": ["USE_UV_ANIM"]
}
}
}
Or you can add this to existing ones, check default material file.
"+defines":[
"USE_UV_ANIM"
]
WARNING
It is not that easy for every entity! Some entities have multiple materials and if you want to make its texture animated, you will need to add this property to all materials of this entity.
Client Entity File
Before we go next, we need to define a new material in our client entity file.
"materials": {
"default": "custom_animated"
}
Render Controllers
After that all, we need to edit a render controller.
Here we will add uv_anim
component with offset and scale properties:
"uv_anim": {
"offset": [ 0.0, "math.mod(math.floor(q.life_time * frames_per_second),frame_count) / frame_count" ],
"scale": [ 1.0, "1 / frame_count" ]
}
Where frames_per_second
is a count of frames you want to change in one second and frame_count
is a total frame count. This formula calculates the offset and the size of the texture depending on life time.
Testing
Now, it is time to test your creation!