- Home /
Do animators cost alot of resources?
Hello. Im creating a 2D game on android. I'm having some problems with optimization. There is a player and multiple enemies with animators attached to them. Each of them have a script with these lines in void Update :
anim.SetFloat("SpeedX", myrigidbody.velocity.x);
anim.SetFloat("SpeedY", myrigidbody.velocity.y);
Then I have the animator play diffrent animations according to SpeedX and SpeedY. So I wanted to ask if this way is efficient or not ?
Answer by mojoceratops · Jun 12, 2017 at 08:46 AM
Get the hashes of the string names of your animator parameters and use those instead of strings.
For example:
private int speedXHash = Animator.StringToHash("SpeedX");
//...
void Update(){
anim.SetFloat(speedXHash, myrigidbody.velocity.x);
}
Your answer
Follow this Question
Related Questions
How can I optimize animations for an android build? 0 Answers
Optimized screens using new UI: SetActive() vs. nested Canvases vs. nested CanvasGroup 2 Answers
Animator.SetFloat causing large CPU Usage 1 Answer
Do Animation Layers Significantly Affect Performance 1 Answer
2D Animation does not start 1 Answer