라벨이 Game인 게시물 표시

Move character

1. Move 2D sprite image using virtual joystick in Unity. 2. I used CrossPlatformInputManager of Unity Standard Asset for joystick script. using System . Collections ; using System . Collections . Generic ; using UnityEngine ; using UnityStandardAssets . CrossPlatformInput ; public class PlayerScript : MonoBehaviour { public static PlayerScript instance ; public float speed ; void Start ( ) { instance = this ; } // Update is called once per frame void Update ( ) { float axisX = CrossPlatformInputManager . GetAxis ( "Horizontal" ) ; float axisY = CrossPlatformInputManager . GetAxis ( "Vertical" ) ; Vector3 moveVec = new Vector3 ( axisX , axisY , 0 ) ; float rot = Mathf . Atan2 ( axisX , axisY ) * Mathf . Rad2Deg ; transform . rotation = Quaternion . Euler ( new Vector3 ( 0 , 0 , - rot ) ) ; this . transform . Translate ( moveVec * speed * Time . de