Any one here know how to have uv’s animating in Unity?
It depends on how you want to animate them. If it’s just scrolling, you can edit texture offsets in the Material using a script:
function Update() {
var offset : Vector2 = renderer.material.mainTextureOffset;
offset += Vector2(1, 1)*Time.deltaTime;
renderer.material.mainTextureOffset = offset;
}
I’m a modeler and 3d artist scripting is not too much of my thing but with this line of code, will i be able to just scroll the texture I need to loop back and forth?
This is a good question. (if I may?) I’ve worked with game engines that will save my texture scrolling from max to the engine from proprietary exporters. Does .fbx save that info? If it doesn’t then I guess it will all have to be done in Unity scripting, yes?
On somewhat the same note,… how about vertex alpha, and animated vertex colors?.. Sorry, I’m not trying to hijack the thread, and if they are in the docs just let me know.
thx
You need to do it through scripting and it isn’t very complex to do actually.
Just a change of UV coordinates over the time
It depends on what you mean by “back and forth”. The code I posted will move the texture in the (1, 1) direction, looping once per second. You can change the values in the Vector2 to make it move faster or slower (or in the opposite direction) in the U and V directions. A useful modification of the script might be to make the vector a variable so you don’t have to change the script itself (I actually simplified it a fair bit by relating the offset directly to time):
var scrollRate : Vector2 = Vector2(1, 1);
function Update() {
renderer.material.mainTextureOffset = scrollRate*Time.time;
}
As far as I know, Unity doesn’t import any vertex-level animation. Vertex colours are supported, and I believe this includes an alpha channel. Vertex-level animation can be done via scripting and the Mesh API.
I know unity can import some form of vertex animation because I am currently doing simple key frame animation in Blender and importing it as an fbx into unity.
http://www.unifycommunity.com/wiki/index.php?title=VertexColor
is what if checked so far…
I think what he means by “back and forth” is like ping pong in Max. Say if you need a police car lights going brighter and darker.
I’ve done the same for cars, blinking lights, and even animated vertex colors on the actual skybox to fake explosions on the horizon based upon simple vertex selection and a text editor.
I’ll have to see if any of this works in Unity… but it won’t be unity at that point, it will still be the exporter. And if filmbox .fbx doesn’t support it then how to do it in Unity is the question? Maybe?..
thx
going back to the original topic for a second,
it might be worth checking out my reply to a post here:
http://forum.unity3d.com/viewtopic.php?t=20492&highlight=animated+fov
in this instance I am using 3dmax XYZ data in order to animate various unity elements including the UV offset.
This was mainly done as a fix while we all wait for 2.6’s amazing animation editor (which will allow such things to be animated from within unity)
but seeing as the OP is from a more 3d background this may be helpful…
Cheers!