|
Okay so I have two objects in my world, one with a looping animation, and one without. The below code is supposed to take the object and move it in front of my avatar. I attach the below code to both objects and the object without the looping animation does exactly what was intended. The object with the looping animation stays in some random place in the world. If I turn the animation off in the inspector the object works as it's supposed to, put it back on and the problem occurs again. Any ideas?
(comments are locked)
|
|
It's because when animating, you should always keep the model at the pivot, because the animation plays in local space with the model. You'll just have to adjust the numbers until it fits right, or reanimate. I guess I'll just change order of operations to attach, animate, loop animation. Pretty unsatisfying answer though :(
Jul 12 '11 at 08:11 PM
zachypin
Well it's just something that you have to understand, animations play in local space - it'd be horrible if they didn't. ;)
Jul 12 '11 at 08:15 PM
Joshua
soz man, it's the only answer there is.
Jul 12 '11 at 08:19 PM
Fishman92
problem still. I edited my code from above to reflect what I'm doing now. You can see that I now turn the animation off when the game starts. Then when I want to turn the animation on I manipulate its position first and then turn the animation on, however the position still doesn't change.
Jul 12 '11 at 08:22 PM
zachypin
I edited it once again and got rid of all the position code except for the initial positioning. So now when the game starts the position of the ufo is correct, right in front of my avatar. As soon as the animation starts, even though no positioning code is being hit, the ufo gets shot off into the world to some random place. -_-
Jul 12 '11 at 08:31 PM
zachypin
(comments are locked)
|
|
I may be way off here, but an idea: Seems that animation curves affect the transform. So does the code, but the animation is 'winning' this fight. What if you reparent the object, with the animation curves on the child, and the animation code on the parent (or vice-versa)? This would still mean that the animation's re-positioning happens after the re-positioning in the Update function, won't it? Giving LateUpdate a try could work though, perhaps. The problem is I have no idea 'when' in a frame the animation is played, I wouldn't be surprised it's saved for the end.
Jul 12 '11 at 08:39 PM
Joshua
(comments are locked)
|
