Skip to content

Instantly share code, notes, and snippets.

@SamatKadyrov
Created December 5, 2023 18:01
Show Gist options
  • Save SamatKadyrov/56cf608a38ae2aafc99078ea3db5d0f5 to your computer and use it in GitHub Desktop.
Save SamatKadyrov/56cf608a38ae2aafc99078ea3db5d0f5 to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TrigonometricFunctions : MonoBehaviour
{
[SerializeField] private Transform _obj; //объект, который будет двигаться
[SerializeField] private float _speed = 2.0f;
[SerializeField] private float _amplitudeX = 1.0f;
[SerializeField] private float _amplitudeY = 1.0f;
private float _angle = 0;
private void Update()
{
_angle += Time.deltaTime * _speed;
_obj.transform.position = new Vector3(_amplitudeX * Mathf.Cos(_angle), _amplitudeY * Mathf.Cos(_angle) * Mathf.Sin(_angle), 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment