- Home /
How would I go about carrying out another object's animation IN C#!
I know in javascript it would go something like: var target = "targetobject"; target.animation.play; thats just a guess of the top of my head,
but can anyone help me out and put that in C#?
Thanks,
this doesn't work, and its all I've found:
public string clip = "DefaultClip"; // Change in inspector to what you want.
then later on:
transform.parent.animation.Play(clip);
That looks like it should work to me. Are you sure that you have both set the proper name and have an Animation component attached to the gameObject of 'transform.parent'?
There should be if you have a public variable in your script and have your script bound to a selected Game Object. If there is not, and you do not have any errors in your Console, then there is another problem.
Answer by MibZ · Jan 26, 2013 at 04:12 AM
animation.Play(string name) plays the animation clip with the name 'name'. That will only make visible difference if you have a clip named "DefaultClip". You only need to know the name of the specific clip you want to play.
Sorry, either you need to explain it a little better, or your not saying anything that is relevant, any other suggestions?