- Home /
Animations aren't found although they are attached to the object
Hello,
first I have to say I am a complete beginner in Unity. I'm in the process of learning how to animate and programm with Unity. I think the answer ia a very easy answer but I can't find it. I already read the first 2 pages on Google for it but it hasn't helped.
What I want to do: I want to programm a NPC. At the moment I'm at a very very basic level. The figure is going a pre-defined way to a table. At the table the figure stops and should pick up a cup an drink form it.
What I managed to do: - The figure is walking in all way - The figure stopps in fornt of the Table
Now my problem comes up: A script attached to the figure is calling a script attached to the cup to start an animation. This animation is the mug moving up from the table to the mouth of the figure. Parallel to it the figure should play an animation where the arm is moving with the cup up to the mouth. But all this doesn't happen. The game stopps when it should call the animation form the cup which is moving the cup up to the mouth.
When I'm attaching the animation as the default animation it says it can't find it.
But I have attached it to the cup.
How do I call the animation?:
In the script from the figure I wrote this in the Updatefunction:
var otherGameObject = GameObject.Find("Becher2");
var otherScript = (TasseMoovement)otherGameObject.GetComponent("TasseMoovement");
otherScript.Tassenbewegung1();
In the script from the cup I wrote this function:
public void Tassenbewegung1()
{
GameObject.Find("Becher2").GetComponent<Animation>().Play("Blendertasse");
}
This function is in the puplic class but not in the start or update function.
I also marked all animations as legacy.
I've copied a script from a related question.
Here it is: (It is in the script form the figure and in the script from the cup included )
public class MeshPostprocessor1 : AssetPostprocessor //all animations marked as Legacy
{
void OnPreprocessModel ()
{
(assetImporter as ModelImporter).animationType = ModelImporterAnimationType.Legacy;
(assetImporter as ModelImporter).materialName = ModelImporterMaterialName.BasedOnMaterialName;
}
}
I really have no clue what is wrong with it. Do you need anymore informations?
I'm programming in C#.
Do you now a other way of doing what I want to do? How could I call the animation from the cup while the animation from the figure is running?
Thanks in advance!