BasicMover.cs 606 B

12345678910111213141516171819
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BasicMover : MonoBehaviour
  5. {
  6. public float UpAndDownAmount = 0.0F;
  7. public Vector3 YPRPerSecond = new Vector3(0.0F, 0.0F, 0.0F);
  8. // Update is called once per frame
  9. void Update()
  10. {
  11. float currentTime = Time.timeSinceLevelLoad;
  12. float previousTime = currentTime - Time.deltaTime;
  13. transform.Translate(0.0F, (Mathf.Sin(currentTime) - Mathf.Sin(previousTime)) * UpAndDownAmount, 0.0F, Space.World);
  14. transform.Rotate(YPRPerSecond * Time.deltaTime, Space.Self);
  15. }
  16. }