Last active
September 27, 2024 11:09
-
-
Save n0mimono/535f58dceb3a4398b1a80cc9f63e278a to your computer and use it in GitHub Desktop.
This file contains 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 Cat : MonoBehaviour | |
{ | |
[SerializeField] GameObject left; | |
[SerializeField] GameObject right; | |
[SerializeField] float radius; | |
[SerializeField] float velocity; | |
[SerializeField] float theta; | |
void Start() | |
{ | |
left.transform.Rotate(0f, 0f, -theta); | |
right.transform.Rotate(0f, 0f, theta); | |
} | |
void Update() | |
{ | |
var v = -velocity * Mathf.Cos(theta * Mathf.Deg2Rad); | |
transform.Rotate(velocity / radius * Mathf.Rad2Deg * Time.deltaTime, 0f, 0f); | |
left.transform.Rotate(v / radius * Mathf.Rad2Deg * Time.deltaTime, 0f, 0f); | |
right.transform.Rotate(v / radius * Mathf.Rad2Deg * Time.deltaTime, 0f, 0f); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment