要让某个物体实时标准有两种方法:
1.用transform.lookat(gameobject.transform) 2.自己书写脚本
Private float curAngle=0; //炮弹的实际角度 Private float angleSpeed=1; //炮塔旋转角度
Void Update() {
sunAngle(); If(curAngle<angle) { curAngle+=angleSpeed; If(curAngle>=angle) { curAngle=angle; } } Else if(curAngle>angle) { curAngle-=angleSpeed; If(curAngle<=angle) { curAngle=angle; } } transform.localEulerAngles=new Vector3(0,cur); }
Void sunAngle() { Float dx=target.transform.position.x-this.transform.position.x; Float dz=target.transform.position.z-this.transform.position.z; Float hudu=Mathf.Atan2(dx,dz); Angle=hudu*180/Math.PI; If(curAngle<0&&Angle>0) //特例1 { curAngle= Angle; } Else
If(curAngle>0&&Angle<0) //特例2 { curAngle= Angle; } }
|