So I created a custom weapon inside of Lightwave, assigned bones, weight maps, animated it, saved the scene, and exported it as a .FBX file. I bring it into Unity and it appears to work fine. If I set the animation to loop and drag the weapon onto the floor of my level and let it go it plays great. So now I attach it to my character and add some code so the animation plays on left mouse click. When I click however, the animation plays but all the pieces of my weapon get thrown out of whack. I was wondering if anyone has experienced this or may know the issue. Below is a link to a video showing the problem as well as the code being used. If more information is needed please let me know and I will try to give as many details as possible.
Hey!
Just sort of an elaboration to @fafase. What I would do, is make your boxing glove box a child object of the camera. Once it is, position it so that it looks like it’s in the right position from the first person view. Then just make sure that you’re animation is attached to the box game object, and make sure the animation is not on loop.
Then just add a simple script to it like this:
function Update(){
if(Input.GetButtonDown("Fire1"){
animation.Play("yourAnimation");
}
}
Then just change yourAnimation to whatever the name of the animation for the box is! Once again, remember to make sure you have the animation attached to the box!
I hope this solves your problem, as I’m sure it’s that script you already have on there that is causing the trouble for you!
If this doesn’t help, then post back and I will see what I can do!
I parented the Boxing Glove Box to the camera and added the script to the boxing glove with the code you gave. It still has all the pieces of my weapon flipping out in different directions.