Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unity 2D 塔防游戏开发01-Sprite和动画
==================================
写unity2d塔防系列文章的目的是记录学习游戏开发的过程.在这系列中并不会把所有关于Unity3D的基础操作都循序渐进的讲一遍,只记录那些自己容易忘记的内容.
###2d角色动画
1,创建4方向的静止和行走动画,共8个.
2,animator里增加X,Y和Static参数用于判断状态的转变.
```
var x = Input.GetAxis("Horizontal");
var y = Input.GetAxis("Vertical");
if (x != 0) y = 0;
animator.SetFloat("Move_X", x);
animator.SetFloat("Move_Y", y);
if (x == 0 && y == 0) {
animator.SetBool("Static", true);
}
else {
animator.SetBool("Static", false);
}
rigidbody2D.velocity = new Vector2(x * moveSpeed, y * moveSpeed);
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.