Hello everyone, first post here.
First off i have gone through quite a few tutorials, i feel i have the basics of unity down fairly well. Im currently working on a project where we have an object with many doors, switches, buttons and so on that all need to be interacted with. The model is done, all animation is set in 3dsmax. I have been able to import it into Unity through FBX, thats working fine and the animation has followed.
I would just like to start with something very basic. So i can wrap my head around scripting. Its something that has always been hard for me to understand
My goal for right now is just to be able to bind one of the animations of this object to a mouse click. So every time i click the left mouse button, a specific animation will play.
Searching the forums and web many times i can find similar topics but cant seem to pull what i need out of them to get the basic understanding of how i need to apply the animation, call it and where to direct the scrip to make it all come together. If i have missed a perfect tutorial for this please let me know but i have noticed most everything involving animation is either for a character, or involving triggers that act on the location of the character. If you have any questions or need clarification please reply!
Thanks for any help you can provide ![]()
Edit:
So with some more digging i found this little helpful piece of treasure.
function Update () {
if (Input.GetButtonDown ("Fire1")) {
animation.Play("drawoneopen");
}
}
Which once i insert my animation name, and attach it to the objects root that has the animation. It works! So exciting. This is one step down a long road haha.
Odd things that are happening:
Its incredibly choppy when it plays the animation, maybe its just my import or something? It seems to of started getting like this after i went into the object and defined the first few animations and added a collider to it from there. Once the animation completes playing, its very smooth again.
Edit2: well the choppy animation i think was due to the creation of the collider when importing the mesh and adding animation, its a very complex vehicle. I assume adding a collider to it probably is choking when animating the 1.5 million polys? Unchecked that and its smooth as butter now.
Next step i need to take, it somehow assign something to a door so that when i click on it, it plays. Ill keep lookin, thanks if you end up chiming in here with a tidbit ![]()
Edit2:Been looking around and i see these OnMouseDown functions that look like they could work? Would i be able to add box colliders to each individal mesh inside this object that needs to be clicked? Is that a good way of doing this? In the end there will be over 1000 parts of it that need to be interacted with in specific orders with rules of when you can do what of course. Just thinking about the future.