The question is answered
why do animated objects not behave like normal GameObjects?
I imported an FBX file that has an animation attached to it. I made it into a prefab and managed to add some of the regular GameObject components like character controller, script, rigidbody, mesh renderer... I can make it move and scale, but not change it's color. Also tried to fix the rotation through the inpsector transform tab but it didnt do anything. When I added a mesh filter it looked like this: http://puu.sh/om8fu.jpg
How can I make it animate and color the same mesh? I want to use
rend = GetComponent<Renderer>();
rend.material.color = color;//set color
to affect the part that's being animated and not add a new mesh.
We want the colored worms to be flat on the ground and animate (curve like the white part), without the white part being there.
Hi, there are a few gaps of information.
Why do you add a mesh renderer and a mesh filter to a fbx model?
When importing a fbx mesh those components should already be there, otherwise you wouldn't see the meshes.The character controller works without a rigidbody.
Don't manually add one to the same GameObject. Check the docs. http://docs.unity3d.com/$$anonymous$$anual/class-CharacterController.htmlDid you check if Unity imports the animation from the fbx file?
Why are there two worms perpenticular to each other? Is this wanted?
Q: How can I make it animate and color the same mesh?
A: Google: "Unity how play animations" & "Unity how to change mesh renderer color"
I want to use
rend = GetComponent<Renderer>();
rend.material.color = color;//set color
to affect the part that's being animated and (1) not add a new mesh.
Just make sure that "rend" is referring to the mesh renderer you want to assign a new color to.
(1) I don't know what you mean by that, you are not adding a new mesh with those two lines of code.
I think i fixed it, but it's probably not in the best way. And no, we don't want 2 perpendicular worms, just 1 that's flat on the floor.
when I import the fbx file it has the animation (Take 001) and a mesh (Line001): http://puu.sh/on9qi.png
but when I drag it into the hierarchy then into the prefab folder to make a prefab where I can add scripts and other components some things dissapear: http://puu.sh/on9AC.png
I kinda made it work by adding a skinned mesh renderer in the Line001 and calling it using rend = GetComponentInChildren<Renderer>();
The rest of the components and the script are in CP1. If i disable the renderer or move it to CP1 it doesnt work. The animator uses the animation file from the non prefab version of CP1.
now it looks like this: http://puu.sh/onajG.jpg, the only problem is that they're moving sideways. I tried to rotate it in 3ds max, as well as in unity by 90 degrees around the y axis.
Prefabs don't contain every asset they are created with, if they did, there would be no point in having prefabs ;)
Please read the documentation on prefabs, it seems you misunderstand them a bit. Here an example from me:
Asset
(fbx from 3ds max): It contains all meshes, animation sequences, etc.
Prefab
(drag fbx into scene, attach scripts, etc.., drag into project folder):
The BabyLimbs Transform has an Animator component created for it because it is the root object of the humanoid bones (the "Done" GameObject is actually the root bone, but the file name (BabyLimbs.fbx) is the root of it all, because it contains everything)
In my case the Beta$$anonymous$$odel001 transform, that is a child of BabyLimbs, has the renderer (in this case a skinned mesh renderer, because the mesh has bones manipulating the vertices).
Once again, you should not add any kind of mesh renderer to an imported model asset. When you drag it into the scene, the transform that has the mesh on it, will automatically have a mesh renderer created for it.
If there is no renderer or animator created for your prefab when you drag the fbx into the scene, make sure you set the import settings correctly.
The sideways moving is solved by recreating the animation in 3ds max and exporting again.
Hope we got it working properly now ;)
thanks, it seems to work now. I at least understand it this much now
This isn't an answer. ;) Please post answers/solutions as "answers", the rest as comments. Check the user guide if you are not sure. I've converted it to a comment.
Glad I could help!
Follow this Question
Related Questions
how to playback a sequence of mesh for a "stop motion" 0 Answers
How to add manual generated color ? 0 Answers
Generate skinned mesh in runtime 1 Answer
voxel stack rendering from mandelbulb? 0 Answers
Animating Colors fails 0 Answers