Hello,
I am stuck! I have been using profiler to track down CG, but have a problem trying to optimize the below code. Has any one any idea how to change the following so it uses less memory?
private Animator animm;
private Vector2 xpos;
public AnimationClip RightAnimation;
public AnimationClip LeftAnimation;
void Start () {
animm = GetComponent<Animator> ();
xpos = this.transform.position;
}
void Update () {
if (this.transform.position.x > xpos.x) {
animm.Play (RightAnimation.name);
}
if (this.transform.position.x < xpos.x) {
animm.Play (LeftAnimation.name);
}
xpos = this.transform.position;
}
}
Thank you,