using UnityEngine; using UnityEngine.UI; public class PlayerRotate902D : MonoBehaviour { public float moveSpeed = 5.0f; public GameObject img; Rigidbody2D rb; Vector2 movement; void Start() { rb = GetComponent(); } void Update() { movement.x = Input.GetAxisRaw("Horizontal"); movement.y = Input.GetAxisRaw("Vertical"); } void FixedUpdate() { if (movement.y > 0) { img.transform.rotation = Quaternion.Euler(0, 0, 90); } else if (movement.y < 0) { img.transform.rotation = Quaternion.Euler(0, 0, -90); } else if (movement.x > 0) { img.transform.rotation = Quaternion.Euler(0, 0, 0); } else if (movement.x < 0) { img.transform.rotation = Quaternion.Euler(0, 0, 180); } rb.MovePosition(rb.position + movement * moveSpeed * 0.02f); } }