Created
December 5, 2023 18:01
-
-
Save SamatKadyrov/56cf608a38ae2aafc99078ea3db5d0f5 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 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