so far this is what i have.
using UnityEngine;
using System.Collections;
public class swingPlatform : MonoBehaviour
{
public int left = 0;
public int right = 0;
public int speed = 60;
void Update()
{
gameObject.transform.Rotate(0, 0, speed * Time.deltaTime);
if(gameObject.transform.rotation.z > left)
{
gameObject.transform.Rotate(0, 0, speed * Time.deltaTime);
}
else if (gameObject.transform.rotation.z < right)
{
gameObject.transform.Rotate(0, 0, -speed * Time.deltaTime);
}
}
}
Here is a bit of code that rotates the platform back and forth. The code produces an eased movement at the ends of the rotation. For a non-eased movement, switch to the line commented out:
using UnityEngine;
using System.Collections;
public class Flipper : MonoBehaviour {
public float speed = 1.0f;
public float maxRotation = 30.0f;
void Update() {
transform.rotation = Quaternion.Euler(0.0f, 0.0f, maxRotation * Mathf.Sin(Time.time * speed));
//transform.rotation = Quaternion.Euler(0.0f, 0.0f, maxRotation * (Mathf.PingPong(Time.time * speed, 2.0f)-1.0f));
}
}