另外一种第三人称写法如下
void usermove(float dt)
{
if (this.move_x == 0 && this.move_y == 0) {
return;
}
BinDebug.Log("move_x:" + this.move_x + ";move_y:" + this.move_y);
//float dir_x = ((float)this.move_x / (float)(1 << 16));
//float dir_y = ((float)this.move_y / (float)(1 << 16));
float dir_x = this.move_x >0 ?1:this.move_x==0?0:-1;
float dir_y = this.move_y>0?1:this.move_y==0?0:-1;
float r = Mathf.Atan2(dir_y, dir_x);
float s = this.speed * dt;
float sx = s * Mathf.Cos(r);
float sz = s * Mathf.Sin(r);
this.transform.Translate(new Vector3(sx, 0, sz), Space.Self);
}