Created
October 2, 2023 12:29
-
-
Save pppoe252110/923e60d995ad904034e1540fc5dafb43 to your computer and use it in GitHub Desktop.
Move Object In Square Shape Formula
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
public class MoveInSquareShape: MonoBehaviour | |
{ | |
public float size = 1f; | |
public float rotation = 0f; | |
private void Update() | |
{ | |
transform.localPosition = Quaternion.Euler(0, 0, rotation) * | |
Vector3.up * size / Mathf.Cos(Mathf.PingPong(rotation, 45f) * Mathf.Deg2Rad) / 2f; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment