using UnityEngine; public class Wiggler : MonoBehaviour { public float wiggleAmount = 1f; // Amount of wiggle (distance) from left to right public float wiggleSpeed = 1f; // Speed of the wiggle private Vector2 startPosition; private float time; public GameObject _LevelManager1; private ButtonDOne script1; private bool einsAn = false; void Start() { startPosition = transform.position; } void Update() { script1 = _LevelManager1.GetComponent(); einsAn = script1.einsAn; if(einsAn){ // Calculate the horizontal position using a sine wave float xPosition = startPosition.x + Mathf.Sin(time * wiggleSpeed) * wiggleAmount; // Set the new position of the game object transform.position = new Vector2(xPosition, transform.position.y); // Increment the time variable based on the elapsed time time += Time.deltaTime;} } }