- Home /
Imported model is not responding to script
Hello everybody,
I made a model and imported it to Unity. In Unity, I animated the model. Now, I want the animation to play when there is a collision with an object.
I'm testing it by dropping a cube down on the model. It does collide and bounce of the model, but it's not responding to the script.
I simply used this JavaScript:
function OnCollisionEnter(){
animation.Play("Animation");
}
Now comes the part I don't understand:
In Unity, I made a cube and animated it. I applied the above script. Then I let something else collide with it. It does exactly what I want it to do: starting the animation on collision.
But when I apply the script to my imported model, there is no response to the script when something collides with it.
What am I doing wrong here? Did I do something wrong when importing the model? The model is a .3ds file.
Thanks.
Answer by alex0091845 · Nov 19, 2012 at 12:02 AM
I think you should change your animation name in your JavaScript where it goes:
animation.Play("Animation");
Is Animation your animation name? If it is, then go to the animated object in Hierarchy panel, then under inspector set its animation to your animation.
Thanks for your answer. It is not the solution I was looking for though. The problem isn't caused by the animation. To check if there even is a collision I replaced the animation.Play line with Debug.Log("collision"); This is also not giving any output to the console.
Your answer
Follow this Question
Related Questions
Attaching an Model via Script. 2 Answers
Ragdoll script vs Extra ragdoll model 0 Answers
(C#) Problem with animations not playing 1 Answer
The compiler this script was imported with is not available anymore 1 Answer
Pickup script not workimg 0 Answers