UnityScripterAI
Discord ↗
Link Copied to Clipboard
×
"move UI element on an arc"
using UnityEngine; using UnityEngine.UI; using System.Collections; public class UIArcMovement : MonoBehaviour { public RectTransform uiElement; public float radius; public float speed; public float angle; private float currentAngle; // Start is called before the first frame update void Start() { currentAngle = angle; } // Update is called once per frame void Update() { currentAngle += speed * Time.deltaTime; float x = radius * Mathf.Cos(currentAngle * Mathf.Deg2Rad); float y = radius * Mathf.Sin(currentAngle * Mathf.Deg2Rad); uiElement.anchoredPosition = new Vector2(x, y); } }