Question by
VincentSai · Sep 09, 2015 at 06:46 PM ·
animatoranimationclipstuck
AnimatorOverrideController not work on android?
Hi I try to use AnimatorOverrideController to modify GameObject position (can't use script because there got additive layer access position). it work fine on editor, but not work on android. Here is my code
if(_Animator == null)
{
_Animator = GetComponent<Animator>();
}
AnimatorOverrideController myOverrideController = new AnimatorOverrideController();
myOverrideController.runtimeAnimatorController = _Animator.runtimeAnimatorController;
AnimationClip inClip = myOverrideController["CenterIn"];
inClip.SetCurve("", typeof(Transform), "localPosition.x", AnimationCurve.Linear(0, posXStart, 1, posXEnd));
inClip.SetCurve("", typeof(Transform), "localPosition.y", AnimationCurve.Linear(0, posYStart, 1, posYEnd));
myOverrideController["CenterIn"] = inClip;
_Animator.runtimeAnimatorController = myOverrideController;
Comment
private Animator _Animator;
public AnimationClip clip;
public AnimationClip clip1;
void Update () {
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.A)) {
if(_Animator == null)
{
_Animator = GetComponent<Animator>();
}
AnimatorOverrideController myOverrideController = new AnimatorOverrideController();
myOverrideController.runtimeAnimatorController = _Animator.runtimeAnimatorController;
myOverrideController["CenterIn"] = clip;
_Animator.runtimeAnimatorController = myOverrideController;
}
if (Input.Get$$anonymous$$eyDown ($$anonymous$$eyCode.S)) {
if(_Animator == null)
{
_Animator = GetComponent<Animator>();
}
AnimatorOverrideController myOverrideController = new AnimatorOverrideController();
myOverrideController.runtimeAnimatorController = _Animator.runtimeAnimatorController;
myOverrideController["CenterIn"] = clip1;
_Animator.runtimeAnimatorController = myOverrideController;
}
}
this code is work! Is AnimationClip.SetCurve only work on editor?