Hi All,
I have a key frame animation being activated when I press the mouse button but the problem is when I try to move the object thru scripting it moves fine but when I pressed the mouse button, the object goes back to the original position.
The mallet animation just goes up and down.
script to test the animation play
var fireRate = 1.0;
private var nextFire = 0.0;
function Update ()
{
if(Input.GetButton("Fire1") Time.time > nextFire)
{
animation["Take 001"].speed = 5;
animation.Play();
nextFire = Time.time + fireRate;
}
if(Input.GetAxis("Horizontal"))
{
transform.Translate(0.5,0,0);
}
}
How can I move the object and play the animation where the object is positioned? What I’m trying to do is, move mallet sideways, press mouse button to whack the clown.
Attaching image too.
Thanks,
Ray

This is something I’ve had a question about, too. I think the only way to resolve this in Unity is to scrap the keyframe animation and use skeletal animation instead. I seem to remember that Blender keyframe animation could occur whereever the object was (it could be set up that way, anyway), but in Unity it always starts with the original position the object was in when you began recording. I wondered if it was possible, in Unity, to record several keyframe animations with different names that could be blended together like a skeletal animation.
I might be off the mark here; I’m not sure if this is what you’re asking.
Hi Terransage
BullsEye!
Will try skeletal anim. Still learning how to animate in Maya and key frame is the easiest for me to learn. Tried blending the existing key frame but no luck.
Thanks,
Ray
Got it to work by adding bones to the mallet and separating the mallet as one object (deleting the rest of the object in the world, this made the mallet transforms to be by itself.) and not part of the whole model, also saving it as different file name.
Thanks for pointing me in that direction!
Ray