Skip to content

Instantly share code, notes, and snippets.

@n0mimono
Last active September 27, 2024 11:09
Show Gist options
  • Save n0mimono/535f58dceb3a4398b1a80cc9f63e278a to your computer and use it in GitHub Desktop.
Save n0mimono/535f58dceb3a4398b1a80cc9f63e278a to your computer and use it in GitHub Desktop.
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