I got a script to show how the pendulum works, Code (csharp): public enum Path { XY, Normal } public Path path; public float speed; public float height; public int freq; void Start() { startPosition = transform.position; } // Update is called once per frame void Update() { if (transform.position.x < startPosition.x || transform.position.x > startPosition.x + distance) { speed *= -1; } float x = transform.position.x + speed * Time.deltaTime; switch ((int)path) { case 0: transform.position = new Vector3(x, startPosition.y + SinPathFunc(x - startPosition.x), transform.position.z); break; case 1: transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.z ); break; } } float SinPathFunc(float x) { float y; y = height * Mathf.Sin((x * Mathf.PI) / (distance / freq)); return y; } but i got a problem, the pendulum is work like this that a bit not suitable for me because i wanna make it like this, so any help?
you're only effecting it triginometrically in the y direction, you need to in the x direction as well. Your x will mostly likely be the Cosine of the angle (this will have a 0 value start you at the top), and your y will be Sine. You'll have a center point, and you'll add the Cos(x) * radius to the x of the center, and you'll add Sin(y) * radius to the y center.