1 usingUnityengine;2 usingSystem.Collections;3 4 Public classMoveceshi:monobehaviour5 {6 Public floatM_speed =5;7 8 PrivateCharactercontroller m_cc;9 Ten voidStart () One { AM_CC = This. Getcomponent<charactercontroller>(); - } - the voidUpdate () - { - floatH = Input.getaxis ("Horizontal"); - floatv = Input.getaxis ("Vertical"); + if(Mathf.abs (h) >0.05f|| Mathf.abs (v) >0.05f) - { + varDIR =NewVector3 (H, V,0); A Rotate (dir); at Move (); - } - - } - voidMove () - { in -M_CC. Simplemove ( This. Transform.forward *m_speed); to } + - voidRotate (Vector3 Dir) the { *Vector3 Screenpos = Camera.main.WorldToScreenPoint ( This. transform.position); $Vector3 destpoint = Screenpos + dir*2;Panax NotoginsengVector3 Worldpos =Camera.main.ScreenToWorldPoint (destpoint); - varTagetpos =NewVector3 (Worldpos.x, This. TRANSFORM.POSITION.Y, worldpos.z); the This. Transform. LookAt (Tagetpos); + A } the}
Unity Full-View Game keyboard operation Displacement-research notes